-
-
Save ziot/ba0fb4e10cf3280a28ad33f509348046 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
''' | |
\Function{GenerateKey}{$B$} | |
\State Initialize an empty string $key$ | |
\For{$i = 1$ to $5$} | |
\State Initialize an empty string $subkey_i$ | |
\For{$j = 1$ to $7$} | |
\If{$i = 1$} | |
\State $str_j \gets \Call{sha512}{B[j]}$ \Comment{$B[j]$ is solution to $jth$ block in chain} | |
\Else | |
\State $str_j \gets \Call{sha512}{subkey_{i-1} \Vert B[j]}$ \Comment{$\Vert$ denotes concatenation} | |
\EndIf | |
\State $subkey_i \gets subkey_i \Vert str_j$ | |
\EndFor | |
\State $key \gets key \Vert subkey_i$ | |
\EndFor | |
\State \textbf{return} $key$ | |
\EndFunction | |
''' | |
def doSha(inputStr): | |
return hashlib.sha512(inputStr.encode()).hexdigest() | |
def doSha3(inputStr): | |
return hashlib.sha3_512(inputStr.encode()).hexdigest() | |
def generateKey(B): | |
key = "" | |
subkey = ["","","","","",""] | |
for i in range(0, 5): | |
for j in range(0, 7): | |
if i == 0: | |
str_j = doSha(B[j]) | |
else: | |
str_j = doSha(subkey[i-1] + B[j]) | |
subkey[i]+=str_j | |
key += subkey[i] | |
return key | |
BlockchainSolutions = [ | |
"poso", | |
"laerania", | |
"a35s6hv", | |
"varyyourtwo", | |
"fmk", | |
"dlul’f’r’", | |
"igna" | |
] | |
key = generateKey(BlockchainSolutions) | |
print(key) | |
# alphabet = "abcdefghijklmnopqrstuvwxyz0123456789()_+-={}|,>?!$[]:/\\" | |
# cipher: Vigenere, Strict case (e.g. A not equal to a), Include foreign characters (include in output, but they do not influence key index)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment