Question
if anyone sees the answer to this question please change it a bit This is python could you answer this as soon as possible? a)Create
if anyone sees the answer to this question please change it a bit
This is python
could you answer this as soon as possible?
a)Create a RSA public/private key pair with 1024 bits key length. The created RSA public {n,e} and private keys {n,d} need to be displayed in the following format:
b)Find a nonce which produces a hash value with hash algorithm SHA-256 satisfying requirement of the 8 least significant bits (LSB) being zero.
this is the hint
You should try many random integers as nonce (with a loop) until you successfully find a nonce that meets the requirement. The only output from this task is the nonce, which needs to be displayed with the following format (suppose the found nonce is 12345):
this is all I have that I did before, so you may need it to answer the question
# Function to shift a character by "shift" units def conv(char,shift): # If char is upper case if(ord(char)>=97 and ord(char)=123): shift_c -= 26 # Take mod if ASCII overflows return (chr(shift_c)) # If char is lower case else: shift_c = (ord(char)+shift) # Shift the char if(shift_c>=91): shift_c -= 26 # Take mod if ASCII overflows return (chr(shift_c)) # Function to find shift using keyword def find_shift(char): val_A = ord('A') # ASCII value of 'A' val_C = ord(char) # ASCII value of char return (val_C-val_A) # Shift = difference in ASCII values # Function to Encrypt Line def encrypt(line,key): idx = 0 str_enc = "" # String to hold encrypted chars # Loop over line characters for i in range(len(line)): # If character is alphabet if(line[i].isalpha()): shift = find_shift(key[idx]) # Find Shift Number using keyword str_enc += conv(line[i],shift) # Shift Character using Shift Number idx = (idx+1)%len(key) # Move to next character in Keyword else: str_enc += line[i] # Return Encrypted String return str_enc # Function to Decrypt Line def decrypt(line,key): idx = 0 str_enc = "" # String to hold decrypted chars # Loop over line characters for i in range(len(line)): # If character is alphabet if(line[i].isalpha()): shift = find_shift(key[idx]) # Find Shift Number using keyword str_enc += conv(line[i],-shift) # Shift Character using Shift Number idx = (idx+1)%len(key) # Move to next character in Keyword else: str_enc += line[i] # Return Encrypted String return str_enc mode = input(" Encryption (E)/Dectyption (D): ") if mode=="E": plain = input("Enter Plaintext: ") else: cipher = input("Enter Ciphertext: ") key_str = input("Enter Keys (Space Seperated): ") keys = key_str.split() # Loop over lines in file and encrypt/decrypt print() for key in keys: key = key.upper() if mode=="D": d_str = decrypt(cipher,key) print("Key: "+key+"\tDecryption: "+d_str) else: e_str = encrypt(plain,key) print("Key: "+key+"\tEncryption: "+e_str)
second part
# Function to shift text by "shift" value def caesar(cipher,shift): # Convert text to list of chars split = list(cipher) # Final key (Initially Empty) final = "" # Iterate over each character for c in split: # Convert char value to ascii and shift backwards val = ord(c) val -= shift # If value goes out of alphabet range, add overflow if val Public key: (n=0x995361030caa5bf308e272fe07f346600727b5ac0c41107142fd97dd75ec4a197250c038 8b8711b210b2beb300980321913e 9eb21b22f72c3fe8b62addal 3491c6efbf3f4e6c6c60738 da c790af2ca0b806754550fae82c8ea85d3fc0667f1de7a193f23a1d30e8e7f2894f07ce26b5d94 85df5a29fc265fc217dbbb91065b35, e=0x10001) Private key: (n=0x995361030caa5bf308e272fe07f3466c0727b5ac0c41107142fd97dd75ec4a197250c038 858711b210b2beb300980321913e9eb21b22f72c3fe8b62adda13491c6efbf3f4e6c6c60738da c790af2ca0b8067f4550 fae82c8ea85d3fc0667f1de7a193f23a1d30e8e7f2894f07ce26b5d94 85df5a29fc265fc217dbbb91065b35, d=0x24cf1913a7d74042dce7ac6ea30efae19568299bb7c769009ff20ca2ec9c010011eb23f28 f40aa7562bfdebb4f91aef2c091557cflb9d7b82651a2663115flee0c416b1fec516a83657558 068fleebffae9f11b2801830acf2b0af4367fcd26ffe4672c5c5165afaeb5eeb81e6497a04192 1334 76e124b4ce2 a 869a16fc998el)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started