mirror of https://github.com/yt-dlp/yt-dlp
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
909 B
Python
35 lines
909 B
Python
12 years ago
|
#!/usr/bin/env python3
|
||
10 years ago
|
from __future__ import unicode_literals, with_statement
|
||
12 years ago
|
|
||
|
import rsa
|
||
|
import json
|
||
|
from binascii import hexlify
|
||
|
|
||
12 years ago
|
try:
|
||
|
input = raw_input
|
||
|
except NameError:
|
||
|
pass
|
||
|
|
||
12 years ago
|
versions_info = json.load(open('update/versions.json'))
|
||
|
if 'signature' in versions_info:
|
||
10 years ago
|
del versions_info['signature']
|
||
12 years ago
|
|
||
|
print('Enter the PKCS1 private key, followed by a blank line:')
|
||
12 years ago
|
privkey = b''
|
||
12 years ago
|
while True:
|
||
10 years ago
|
try:
|
||
|
line = input()
|
||
|
except EOFError:
|
||
|
break
|
||
|
if line == '':
|
||
|
break
|
||
|
privkey += line.encode('ascii') + b'\n'
|
||
12 years ago
|
privkey = rsa.PrivateKey.load_pkcs1(privkey)
|
||
|
|
||
|
signature = hexlify(rsa.pkcs1.sign(json.dumps(versions_info, sort_keys=True).encode('utf-8'), privkey, 'SHA-256')).decode()
|
||
|
print('signature: ' + signature)
|
||
|
|
||
|
versions_info['signature'] = signature
|
||
10 years ago
|
with open('update/versions.json', 'w') as versionsf:
|
||
|
json.dump(versions_info, versionsf, indent=4, sort_keys=True)
|