logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

sign-versions.py (909B)


  1. #!/usr/bin/env python3
  2. from __future__ import unicode_literals, with_statement
  3. import rsa
  4. import json
  5. from binascii import hexlify
  6. try:
  7. input = raw_input
  8. except NameError:
  9. pass
  10. versions_info = json.load(open('update/versions.json'))
  11. if 'signature' in versions_info:
  12. del versions_info['signature']
  13. print('Enter the PKCS1 private key, followed by a blank line:')
  14. privkey = b''
  15. while True:
  16. try:
  17. line = input()
  18. except EOFError:
  19. break
  20. if line == '':
  21. break
  22. privkey += line.encode('ascii') + b'\n'
  23. privkey = rsa.PrivateKey.load_pkcs1(privkey)
  24. signature = hexlify(rsa.pkcs1.sign(json.dumps(versions_info, sort_keys=True).encode('utf-8'), privkey, 'SHA-256')).decode()
  25. print('signature: ' + signature)
  26. versions_info['signature'] = signature
  27. with open('update/versions.json', 'w') as versionsf:
  28. json.dump(versions_info, versionsf, indent=4, sort_keys=True)