todella vähän parempi shashasha

This commit is contained in:
kalzu 2023-05-25 22:47:04 +03:00
parent 6528b2401e
commit dc393eecf5

View File

@ -1,4 +1,8 @@
#!/usr/bin/python3.10 #!/usr/bin/python3.10
"""
This is simple script that gives out quite random chars.
Like we almost won eurovision.
"""
from hashlib import sha256 from hashlib import sha256
from random import randint from random import randint
@ -7,19 +11,21 @@ runs = 400
turn = 0 turn = 0
start = "Hello There, friend!" start = "Hello There, friend!"
def turns_and_runs(turn, input, end): def turns_and_runs(turn, input, end):
input_bytes = input.encode() input_bytes = input.encode()
input_hash = sha256(input_bytes) input_hash = sha256(input_bytes)
return_blob = input_hash.hexdigest() return_blob = input_hash.hexdigest()
if turn < runs: if turn < runs:
my_random = randint(10, 60) my_random = randint(10, 60)
end += return_blob[my_random] end += return_blob[my_random]
return_blob = return_blob + return_blob + str(my_random) return_blob = return_blob + return_blob + str(my_random)
end = turns_and_runs(turn + 1, return_blob, end) end = turns_and_runs(turn + 1, return_blob, end)
return end return end
result = turns_and_runs(turn, start, '')
result = turns_and_runs(turn, start, "")
print(result) print(result)