global_info="All files are interpreted as raw bytes and must be located in the directory with this executable file.\nDefault filenames with .bin extension: pubkey, privkey_S, privkey_p, plaintext, ciphertext, ciphered_string.\nDon't forget to import (or generate) keys before encryption/decryption and after changing config!\nYou can restore any one key from two another (don't forget to import before).\n"
info="Menu numbers: 0 = exit, s = print short info, h = print this info, g = print global info, c = change config;\n1 = generate keys, 10 = unsafe generate keys (seed = hash(password)),\n11 = export pubkey, 12 = export privkey_S, 13 = export privkey_p,\n14 = import pubkey, 15 = import privkey_S, 16 = import privkey_p,\n17 = restore pubkey, 18 = restore privkey_S, 19 = restore privkey_p;\n2 = encrypt,\n21 = encrypt non-default filename, 22 = encrypt string from keyboard, 23 = encrypt hided string.\n3 = decrypt,\n31 = decrypt non-default filename, 32 = decrypt string and show on screen\n"
print("\nMcEliece cryptosystem implementation by vovuas2003. Version 2.\n")
print(global_info)
print(info)
whileTrue:
s=input("Menu number: ")
whilesnotininp:
s=input("Wrong menu number; h = help, s = short help: ")
ifs=='0':
print("\nGood luck!")
break
elifs=='s':
print(short_info)
elifs=='h':
print(info)
elifs=='g':
print(global_info)
elifs=='c':
n,k=core.get_config()
print("Default config is 255 210, current is "+str(n)+""+str(k)+". Change config? Also reset all keys!")
if(notget_yes_no()):
continue
try:
print("Config is two numbers n >= k >= 2; (3 * 5 * 17) mod n = 0. Larger values = larger keys.\nRandomly change (n - k) div 2 bytes during encryption, but add (n - k + 1) bytes to each chunk with len (k - 1).")
n,k=map(int,input("Write n and k separated by a space: ").split())
core.change_config(n,k)
print(ok)
except:
print(err)
elifs=='1':
print("Reset all keys!")
if(notget_yes_no()):
continue
try:
core.generate_keys()
print(ok)
except:
print(err)
elifs=='10':
print("It is better to use menu number 1 for true random!")
if(notget_yes_no()):
continue
try:
core.generate_keys(normalhash(getpass.getpass("Password for hash: ")))