Mise à jour effectuée, merci de nous signaler tout dysfonctionnement ! | Upgrade done, please let us know about any dysfunction!

Commit 0f38930b authored by Moul's avatar Moul

[enh] #71: add helpers to convert seed into seedhex and vice versa

parent ebb6ee3e
from typing import Union
from libnacl.encode import hex_decode, hex_encode
def ensure_bytes(data: Union[str, bytes]) -> bytes:
......@@ -39,3 +40,23 @@ def xor_bytes(b1: bytes, b2: bytes) -> bytearray:
for i1, i2 in zip(b1, b2):
result.append(i1 ^ i2)
return result
def convert_seedhex_to_seed(seedhex: str) -> bytes:
Convert seedhex to seed
:param seedhex: seed coded in hexadecimal base
:rtype bytes:
return bytes(hex_decode(seedhex.encode("utf-8")))
def convert_seed_to_seedhex(seed: bytes) -> str:
Convert seed to seedhex
:param seed: seed
:rtype str:
return hex_encode(seed).decode("utf-8")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment