From dc393eecf547cc7461ac627dae142466b1807ebf Mon Sep 17 00:00:00 2001 From: kalzu Date: Thu, 25 May 2023 22:47:04 +0300 Subject: [PATCH] =?UTF-8?q?todella=20v=C3=A4h=C3=A4n=20parempi=20shashasha?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shashasha.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/shashasha.py b/shashasha.py index 5a84cb2..5936a82 100755 --- a/shashasha.py +++ b/shashasha.py @@ -1,4 +1,8 @@ #!/usr/bin/python3.10 +""" +This is simple script that gives out quite random chars. +Like we almost won eurovision. +""" from hashlib import sha256 from random import randint @@ -7,19 +11,21 @@ runs = 400 turn = 0 start = "Hello There, friend!" + def turns_and_runs(turn, input, end): - input_bytes = input.encode() - input_hash = sha256(input_bytes) - return_blob = input_hash.hexdigest() + input_bytes = input.encode() + input_hash = sha256(input_bytes) + return_blob = input_hash.hexdigest() - if turn < runs: - my_random = randint(10, 60) - end += return_blob[my_random] - return_blob = return_blob + return_blob + str(my_random) - end = turns_and_runs(turn + 1, return_blob, end) + if turn < runs: + my_random = randint(10, 60) + end += return_blob[my_random] + return_blob = return_blob + return_blob + str(my_random) + 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)