本文整理汇总了Python中simon.SimonCipher.decrypt方法的典型用法代码示例。如果您正苦于以下问题:Python SimonCipher.decrypt方法的具体用法?Python SimonCipher.decrypt怎么用?Python SimonCipher.decrypt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simon.SimonCipher
的用法示例。
在下文中一共展示了SimonCipher.decrypt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_simon128_256
# 需要导入模块: from simon import SimonCipher [as 别名]
# 或者: from simon.SimonCipher import decrypt [as 别名]
def test_simon128_256(self):
block_size = 128
key_size = 256
for x in range(self.test_cnt):
key = randint(0, (2**key_size) - 1)
plaintxt = randint(0, (2**block_size) - 1)
c = SimonCipher(key, key_size, block_size, 'ECB')
assert c.decrypt(c.encrypt(plaintxt)) == plaintxt, 'Test %r Failed with Random Key %r and Random Plaintext %r' % (x, hex(key), hex(plaintxt))
示例2: test_ofb_mode_chain
# 需要导入模块: from simon import SimonCipher [as 别名]
# 或者: from simon.SimonCipher import decrypt [as 别名]
def test_ofb_mode_chain(self):
plaintxts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
c = SimonCipher(self.key, self.key_size, self.block_size, 'OFB', init=self.iv)
ciphertexts = [c.encrypt(x) for x in plaintxts]
c = SimonCipher(self.key, self.key_size, self.block_size, 'OFB', init=self.iv)
decryptexts = [c.decrypt(x) for x in ciphertexts]
assert plaintxts == decryptexts
示例3: test_simon128_256
# 需要导入模块: from simon import SimonCipher [as 别名]
# 或者: from simon.SimonCipher import decrypt [as 别名]
def test_simon128_256(self):
key = 0x1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100
plaintxt = 0x74206e69206d6f6f6d69732061207369
ciphertxt = 0x8d2b5579afc8a3a03bf72a87efe7b868
block_size = 128
key_size = 256
c = SimonCipher(key, key_size, block_size, 'ECB')
assert c.encrypt(plaintxt) == ciphertxt
assert c.decrypt(ciphertxt) == plaintxt
示例4: test_simon128_192
# 需要导入模块: from simon import SimonCipher [as 别名]
# 或者: from simon.SimonCipher import decrypt [as 别名]
def test_simon128_192(self):
key = 0x17161514131211100f0e0d0c0b0a09080706050403020100
plaintxt = 0x206572656874206e6568772065626972
ciphertxt = 0xc4ac61effcdc0d4f6c9c8d6e2597b85b
block_size = 128
key_size = 192
c = SimonCipher(key, key_size, block_size, 'ECB')
assert c.encrypt(plaintxt) == ciphertxt
assert c.decrypt(ciphertxt) == plaintxt
示例5: test_simon128_128
# 需要导入模块: from simon import SimonCipher [as 别名]
# 或者: from simon.SimonCipher import decrypt [as 别名]
def test_simon128_128(self):
key = 0x0f0e0d0c0b0a09080706050403020100
plaintxt = 0x63736564207372656c6c657661727420
ciphertxt = 0x49681b1e1e54fe3f65aa832af84e0bbc
block_size = 128
key_size = 128
c = SimonCipher(key, key_size, block_size, 'ECB')
assert c.encrypt(plaintxt) == ciphertxt
assert c.decrypt(ciphertxt) == plaintxt
示例6: test_simon96_144
# 需要导入模块: from simon import SimonCipher [as 别名]
# 或者: from simon.SimonCipher import decrypt [as 别名]
def test_simon96_144(self):
key = 0x1514131211100d0c0b0a0908050403020100
plaintxt = 0x74616874207473756420666f
ciphertxt = 0xecad1c6c451e3f59c5db1ae9
block_size = 96
key_size = 144
c = SimonCipher(key, key_size, block_size, 'ECB')
assert c.encrypt(plaintxt) == ciphertxt
assert c.decrypt(ciphertxt) == plaintxt
示例7: test_simon96_96
# 需要导入模块: from simon import SimonCipher [as 别名]
# 或者: from simon.SimonCipher import decrypt [as 别名]
def test_simon96_96(self):
key = 0x0d0c0b0a0908050403020100
plaintxt = 0x2072616c6c69702065687420
ciphertxt = 0x602807a462b469063d8ff082
block_size = 96
key_size = 96
c = SimonCipher(key, key_size, block_size, 'ECB')
assert c.encrypt(plaintxt) == ciphertxt
assert c.decrypt(ciphertxt) == plaintxt
示例8: test_simon64_128
# 需要导入模块: from simon import SimonCipher [as 别名]
# 或者: from simon.SimonCipher import decrypt [as 别名]
def test_simon64_128(self):
key = 0x1b1a1918131211100b0a090803020100
plaintxt = 0x656b696c20646e75
ciphertxt = 0x44c8fc20b9dfa07a
block_size = 64
key_size = 128
c = SimonCipher(key, key_size, block_size, 'ECB')
assert c.encrypt(plaintxt) == ciphertxt
assert c.decrypt(ciphertxt) == plaintxt
示例9: test_simon64_96
# 需要导入模块: from simon import SimonCipher [as 别名]
# 或者: from simon.SimonCipher import decrypt [as 别名]
def test_simon64_96(self):
key = 0x131211100b0a090803020100
plaintxt = 0x6f7220676e696c63
ciphertxt = 0x5ca2e27f111a8fc8
block_size = 64
key_size = 96
c = SimonCipher(key, key_size, block_size, 'ECB')
assert c.encrypt(plaintxt) == ciphertxt
assert c.decrypt(ciphertxt) == plaintxt
示例10: test_simon48_96
# 需要导入模块: from simon import SimonCipher [as 别名]
# 或者: from simon.SimonCipher import decrypt [as 别名]
def test_simon48_96(self):
key = 0x1a19181211100a0908020100
plaintxt = 0x72696320646e
ciphertxt = 0x6e06a5acf156
block_size = 48
key_size = 96
c = SimonCipher(key, key_size, block_size, 'ECB')
assert c.encrypt(plaintxt) == ciphertxt
assert c.decrypt(ciphertxt) == plaintxt
示例11: test_simon48_72
# 需要导入模块: from simon import SimonCipher [as 别名]
# 或者: from simon.SimonCipher import decrypt [as 别名]
def test_simon48_72(self):
key = 0x1211100a0908020100
plaintxt = 0x6120676e696c
ciphertxt = 0xdae5ac292cac
block_size = 48
key_size = 72
c = SimonCipher(key, key_size, block_size, 'ECB')
assert c.encrypt(plaintxt) == ciphertxt
assert c.decrypt(ciphertxt) == plaintxt
示例12: test_simon32_64
# 需要导入模块: from simon import SimonCipher [as 别名]
# 或者: from simon.SimonCipher import decrypt [as 别名]
def test_simon32_64(self):
key = 0x1918111009080100
plaintxt = 0x65656877
ciphertxt = 0xc69be9bb
block_size = 32
key_size = 64
c = SimonCipher(key, key_size, block_size, 'ECB')
assert c.encrypt(plaintxt) == ciphertxt
assert c.decrypt(ciphertxt) == plaintxt
示例13: test_ofb_mode_equivalent
# 需要导入模块: from simon import SimonCipher [as 别名]
# 或者: from simon.SimonCipher import decrypt [as 别名]
def test_ofb_mode_equivalent(self):
c = SimonCipher(self.key, self.key_size, self.block_size, 'OFB', init=self.iv)
ofb_encrypt = c.encrypt(self.plaintxt)
c = SimonCipher(self.key, self.key_size, self.block_size, 'OFB', init=self.iv)
ofb_decrypt = c.decrypt(ofb_encrypt)
c = SimonCipher(self.key, self.key_size, self.block_size, 'ECB')
ecb_out = c.encrypt(self.iv)
ofb_equivalent_encrypt = ecb_out ^ self.plaintxt
ofb_equivalent_decrypt = ecb_out ^ ofb_equivalent_encrypt
assert ofb_encrypt == ofb_equivalent_encrypt
assert ofb_decrypt == ofb_equivalent_decrypt
示例14: test_ctr_mode_single_cycle
# 需要导入模块: from simon import SimonCipher [as 别名]
# 或者: from simon.SimonCipher import decrypt [as 别名]
def test_ctr_mode_single_cycle(self):
self.counter = 0x01
c = SimonCipher(self.key, self.key_size, self.block_size, 'CTR', init=self.iv, counter=self.counter)
ctr_out = c.encrypt(self.plaintxt)
self.counter = 0x01
c = SimonCipher(self.key, self.key_size, self.block_size, 'CTR', init=self.iv, counter=self.counter)
output_plaintext = c.decrypt(ctr_out)
assert output_plaintext == self.plaintxt
示例15: argon2_test
# 需要导入模块: from simon import SimonCipher [as 别名]
# 或者: from simon.SimonCipher import decrypt [as 别名]
def argon2_test():
start = time.time()
ph = PasswordHasher()
hash = ph.hash(password)
hashed = hashlib.sha256(hash).digest()
end = time.time()
print "argon2 : ",(end-start)
start = time.time()
obj =AES.new(hashed,AES.MODE_CBC, 'This is an IV456')
ciphertext = obj.encrypt("The answer is no")
end = time.time()
print "AES Encrypt: ",(end-start)*1000
start = time.time()
obj =AES.new(hashed,AES.MODE_CBC, 'This is an IV456')
plaintext = obj.decrypt(ciphertext)
end = time.time()
print "AES Decrypt: ",(end-start)*1000
my_plaintext = 0xCCCCAAAA55553333
start = time.time()
big_cipher = SimonCipher(0x111122223333444455556666777788889999AAAABBBBCCCCDDDDEEEEFFFF0000, key_size=256, block_size=128)
simon = big_cipher.encrypt(my_plaintext)
end = time.time()
print "Simon Encrypt: ",(end-start)*1000
start = time.time()
big_cipher1 = SpeckCipher(0x111122223333444455556666777788889999AAAABBBBCCCCDDDDEEEEFFFF0000, key_size=256, block_size=128)
speck = big_cipher1.encrypt(my_plaintext)
end = time.time()
print "Speck Encrypt: ",(end-start)*1000
start = time.time()
big_cipher = SimonCipher(0x111122223333444455556666777788889999AAAABBBBCCCCDDDDEEEEFFFF0000, key_size=256, block_size=128)
plain = big_cipher.decrypt(simon)
end = time.time()
print plain
print "Simon Decrypt: ",(end-start)*1000
start = time.time()
big_cipher1 = SpeckCipher(0x111122223333444455556666777788889999AAAABBBBCCCCDDDDEEEEFFFF0000, key_size=256, block_size=128)
plain = big_cipher1.decrypt(speck)
end = time.time()
print plain
print "Speck Decrypt: ",(end-start)*1000