This commit is contained in:
Captain Nick Lucifer* 2023-03-11 11:16:21 +05:45
commit 19afe0af48
1 changed files with 34 additions and 0 deletions

34
k-i-e-3-ja-pun.py Normal file
View File

@ -0,0 +1,34 @@
#!/shebang
import json
import random
from base64 import b64decode, b64encode
from hashlib import sha512
from getch import getch, getche
def printf(*args, **kwargs):
print(*args, **kwargs, end='', flush=True)
def sign(msg, iv):
if type(msg) == str:
msg = msg.encode()
elif type(msg) != bytearray or type(msg) != bytes:
raise ValueError("Byte! m8!")
return b64encode(sha512(msg).digest() + sha512(iv).digest()).decode()
def main():
printf("Press any key to generate one.")
getch()
print()
ivb = getche().encode()
iv = ivb + random.randbytes(31)
msg = 'Pv!'
test = sign(msg, iv)
print(msg)
print(test)
print(json.dumps({'iv': sha512(iv).hexdigest(), 'msg' : msg, 'msg_hash': test}))
if __name__ == '__main__':
main()