コード例 #1
0
ファイル: main.py プロジェクト: Bouncer00/Cryptography
def main():
  print(sys.argv)
  CRT = True
  k = 6
  d = 256
  keygen = Keygen()
  decryptor = Decryptor()
  encryptor = Encryptor()
  file_processor = File_processor()
  keys = keygen.generate_keys(k,  d, CRT)
  file_processor.save_keys(keys, CRT)
  file_processor.read_keys(CRT)
  start_time = timer()
  encrypted = encryptor.encrypt(keys['public_n'], keys['public_e'], 'data/plain.txt', CRT)
  print("ENCRYPTION TIME MEASUE:")
  print(timer() - start_time) 
  start_time = timer()
  decrypted = decryptor.decrypt(keys, CRT, k, 'data/plain.txt.enc')
  print("DECRYPTION TIME MEASUE:")
  print(timer() - start_time) 
  print(decrypted)
  return 0
コード例 #2
0
ファイル: main.py プロジェクト: Bouncer00/Cryptography
  print("DECRYPTION TIME MEASUE:")
  print(timer() - start_time) 
  print(decrypted)
  return 0


if __name__ == "__main__":
  if sys.argv[1] == 'test':
    main()
  elif sys.argv[1] == 'gen':
    k, d = int(sys.argv[2]), int(sys.argv[3])
    CRT = True if int(sys.argv[4]) == 1 else False
    keygen = Keygen()
    file_processor = File_processor()
    start_time = timer()
    keys = keygen.generate_keys(k,  d, CRT)
    file_processor.save_keys(keys, CRT)
  elif sys.argv[1] == 'enc':
    CRT = True if int(sys.argv[2]) == 1 else False
    file_processor = File_processor()
    keys = file_processor.read_keys(CRT)
    encryptor = Encryptor()
    start_time = timer()
    encrypted = encryptor.encrypt(keys['public_n'], keys['public_e'], 'data/plain.txt', CRT)
    print("ENCRYPTION TIME MEASUE:")
    print(timer() - start_time) 
  elif sys.argv[1] == 'dec':
    k = int(sys.argv[2])
    CRT = True if int(sys.argv[3]) == 1 else False
    file_processor = File_processor()
    keys = file_processor.read_keys(CRT)