Обновить py/converter.py

This commit is contained in:
artemuhi 2024-03-23 14:11:31 +03:00
parent 841f091d1c
commit cd94855415

View File

@ -28,25 +28,25 @@ import json
from ecdsa import SigningKey, VerifyingKey, SECP256k1 from ecdsa import SigningKey, VerifyingKey, SECP256k1
from ecdsa.util import PRNG from ecdsa.util import PRNG
f = open('text.txt', 'r') f = open('temp.json', 'r')
request = json.load(f) request = json.load(f)
f.close() f.close()
def p2h(data, keymode): def p2h(data, keymode):
if(keymode=="sk"): if(keymode=="sk"):
sk = SigningKey.from_pem(data, curve=SECP256k1) sk = SigningKey.from_pem(data.encode(), curve=SECP256k1)
print(sk.to_string().hex()) print(sk.to_string().hex())
elif(keymode=="vk"): elif(keymode=="vk"):
vk = VerifyingKey.from_pem(data, curve=SECP256k1) vk = VerifyingKey.from_pem(data.encode(), curve=SECP256k1)
print(vk.to_string().hex()) print(vk.to_string().hex())
def h2p(data, keymode): def h2p(data, keymode):
if(keymode=="sk"): if(keymode=="sk"):
sk = SigningKey.from_string(b16decode(data), curve=SECP256k1) sk = SigningKey.from_string(b16decode(data.encode()), curve=SECP256k1)
print(sk.to_pem()) print(sk.to_pem().decode())
elif(keymode=="vk"): elif(keymode=="vk"):
vk = VerifyingKey.from_string(b16decode(data), curve=SECP256k1) vk = VerifyingKey.from_string(b16decode(data.encode()), curve=SECP256k1)
print(vk.to_pem()) print(vk.to_pem().decode())
def seed2hkey(data, keymode): def seed2hkey(data, keymode):
seed = PRNG(data.encode()) seed = PRNG(data.encode())