OSDN Git Service
(root)
/
bytom
/
bytom-kit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
b133e85
)
refine create_entropy
author
Chengcheng Zhang
<943420582@qq.com>
Wed, 13 Feb 2019 04:16:02 +0000
(12:16 +0800)
committer
Chengcheng Zhang
<943420582@qq.com>
Wed, 13 Feb 2019 04:16:02 +0000
(12:16 +0800)
app/model/key.py
patch
|
blob
|
history
diff --git
a/app/model/key.py
b/app/model/key.py
index
5057d00
..
fc8a02f
100644
(file)
--- a/
app/model/key.py
+++ b/
app/model/key.py
@@
-10,12
+10,8
@@
from app.model import receiver
# create_key create 128 bits entropy
def create_entropy():
- hex_str = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"]
- entropy_str = ""
- for _ in range(32):
- # create interger in range [1,15]
- num = random.randint(0,15)
- entropy_str += hex_str[num]
+ entropy = random.randint(0, 2**128)
+ entropy_str = entropy.to_bytes(16, byteorder='big').hex()
return {
"entropy": entropy_str
}