Skip to content

Commit 8eb7785

Browse files
committed
Update readme
1 parent 5c1b2c4 commit 8eb7785

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,36 @@ comb = secrets.combine(shares[:4] + [new_share])
6767
print(comb == key) # => True
6868
```
6969

70+
Divide a password containing a mix of numbers, letters, and other characters, requiring that any 3 shares must be present to reconstruct the original password:
71+
72+
```python
73+
import js2pysecrets as secrets
74+
75+
pw = "<<PassWord123>>"
76+
77+
# convert the text into a hex string
78+
pwHex = secrets.str2hex(pw)
79+
print(pwHex) # => hex string
80+
81+
# split into 5 shares, with a threshold of 3
82+
shares = secrets.share(pwHex, 5, 3)
83+
print(shares) # => ['801xxx...xxx','802xxx...xxx', ... ,'804xxx...xxx','805xxx...xxx']
84+
85+
# combine 2 shares:
86+
comb = secrets.combine(shares[:2])
87+
88+
//convert back to UTF string:
89+
comb = secrets.hex2str(comb)
90+
print(comb === pw) # => False
91+
92+
// combine 3 shares:
93+
comb = secrets.combine([shares[1], shares[3], shares[4]])
94+
95+
//convert back to UTF string:
96+
comb = secrets.hex2str(comb)
97+
print(comb === pw) # => True
98+
```
99+
70100
---
71101

72102
This is a `Python` implementation of [Shamir's threshold secret sharing scheme](http://en.wikipedia.org/wiki/Shamir's_Secret_Sharing), based **and compatible with** the `JavaScript` fork of `secrets.js` [*maintained by `grempe`*](https://github.com/grempe/secrets.js). Which is orginally based on the code created by `amper5and` on Github. The [original secrets.js can be found there](https://github.com/amper5and/secrets.js/).

0 commit comments

Comments
 (0)