Generating a Cryptographic Key Using Fibonacci Sequence in Python
I'm Trying to Generate a Cryptographic Key Using the Fibonacci Sequence in Python. I Have a Specific Key (Ebe42A225E8593E448D9C5457381Aaf7) That I Want to Use...
I'm trying to generate a cryptographic key using the Fibonacci sequence in Python. I have a specific key (ebe42a225e8593e448d9c5457381aaf7) that I want to use as a starting point. However, my current implementation is not working as expected. Could someone please help me identify the issue in my code and provide guidance on how to achieve this?
def generate_key_from_fibonacci(seed_key):
# Convert the seed key from hexadecimal to an integer
seed_key_int = int(seed_key, 16)
# Generate Fibonacci numbers until the key length is reached
fib_nums = [0, 1]
while len(fib_nums[-1]) < len(seed_key):
next_fib = fib_nums[-1] + fib_nums[-2]
fib_nums.append(next_fib)
# Truncate or expand the last Fibonacci number to match the key length
fib_nums[-1] = fib_nums[-1][:len(seed_key)]
# XOR each Fibonacci number with the seed key
key = hex(int(seed_key, 16) ^ int(fib_nums[-1], 2))[2:]
return key
seed_key = 'ebe42a225e8593e448d9c5457381aaf7'
generated_key = generate_key_from_fibonacci(seed_key)
print("Generated Key:", generated_key)
I would greatly appreciate any assistance or suggestions on how to modify my code to generate a cryptographic key using the Fibonacci sequence in Python. Thank you in advance.
Thank you for helping me.