initial save of my chatGPT coding
This commit is contained in:
30
shared-secret/chatgpt-example.py
Executable file
30
shared-secret/chatgpt-example.py
Executable file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
from secretsharing import PlaintextToHexSecretSharer
|
||||
|
||||
# The secret that we want to split
|
||||
secret = "my_secret_password"
|
||||
|
||||
# The number of shares that we want to generate
|
||||
n_shares = 5
|
||||
|
||||
# The threshold (i.e., the minimum number of shares required to reconstruct the secret)
|
||||
threshold = 3
|
||||
|
||||
# Generate the shares
|
||||
shares = PlaintextToHexSecretSharer.split_secret(secret, n_shares, threshold)
|
||||
|
||||
# Print the shares
|
||||
for share in shares:
|
||||
print(share)
|
||||
|
||||
# To reconstruct the secret, we need at least the threshold number of shares
|
||||
# Let's say we have these three shares:
|
||||
shares_to_reconstruct = [shares[0], shares[2], shares[4]]
|
||||
|
||||
# Reconstruct the secret
|
||||
secret = PlaintextToHexSecretSharer.recover_secret(shares_to_reconstruct)
|
||||
|
||||
# Print the secret
|
||||
print(secret)
|
||||
|
Reference in New Issue
Block a user