您好
在下面的code當中,在ubuntu16.04下使用python3去build 會有問題(python2也是不行的)
請問我要bulidt 成 level 1,相信這是很重要的步驟,可以請您回覆我?
謝謝
#!/usr/bin/env python3
from Crypto.Cipher import AES
from Crypto.Random import get_random_bytes
from argparse import FileType
import argparse
parser = argparse.ArgumentParser(description='Provisioning encryption tool.')
parser.add_argument('key', type = file)
parser.add_argument('plaintext', type = file)
parser.add_argument('ciphertext', type = argparse.FileType('w'))
parser.add_argument('nonce', type = argparse.FileType('w'))
parser.add_argument('tag', type = argparse.FileType('w'))
args = parser.parse_args()
data = args.plaintext.read()
key = args.key.read()
nonce = get_random_bytes(7)
data += '\0' * (((len(data)+15)/16 * 16) - len(data))
cipher = AES.new(key, AES.MODE_CCM, nonce)
ciphertext, tag = cipher.encrypt_and_digest(data)
cipher = AES.new(key, AES.MODE_CCM, nonce)
plaintext = cipher.decrypt_and_verify(ciphertext, tag)
if (plaintext != data):
print ("Encryption error.")
else:
args.nonce.write(nonce)
args.tag.write(tag)
args.ciphertext.write(ciphertext)
print ("ncryption done. ")