Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DuniterPy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
python
DuniterPy
Commits
0f38930b
Commit
0f38930b
authored
6 years ago
by
Moul
Browse files
Options
Downloads
Patches
Plain Diff
[enh]
#71
: add helpers to convert seed into seedhex and vice versa
parent
ebb6ee3e
No related branches found
No related tags found
1 merge request
!54
#71: handle seedhex
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
duniterpy/helpers.py
+21
-0
21 additions, 0 deletions
duniterpy/helpers.py
with
21 additions
and
0 deletions
duniterpy/helpers.py
+
21
−
0
View file @
0f38930b
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
"
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment