test Environment:
CPU 1-Core Intel 2.2GHZ
Memory 1GB
| algorithm |
type |
| Symmetric encryption algorithm |
AES CBC Mode |
| Asymmetric encryption algorithm |
RSA 256 |
Encrypted plaintext length is bytes
Run 10,000 times each
On the Code test_aes.py
fromCrypto.cipher Import Aesimport Timeobj = AES.New(' This is a key123 'Aes. MODE_CBC,' This was an IV456 ') message =' A '* theT1 = Time. Time() forIinchXrange10000): ciphertext = obj.Encrypt(message) Obj2 = AES.New(' This is a key123 'Aes. MODE_CBC,' This was an IV456 ')text= Obj2.Decrypt(ciphertext)#print Textt2 = Time. Time() Print T2-t1
test_rsa.py
fromCrypto.publickey Import Rsaimport TimeT1 = Time. Time() key = Rsa.generate (2048) T2 = Time. Time() Print' Gen key ', T2-T1#print Key#print Key.exportkey ()#print rsa.exportkey (' PEM ')Message =' A '* theT1 = Time. Time() forIinchXrange10000): print I ciphertext = key.Encrypt(Message, None) key.Decrypt(ciphertext) t2 = Time. Time() Print T2-t1
| algorithm |
Time Consuming |
| Symmetric encryption algorithm |
0.13 |
| Asymmetric encryption algorithm |
193.16 |
| Asymmetric encryption algorithm generates key pair |
0.68 |
Symmetric encryption algorithms are about 1500 times times faster than asymmetric encryption algorithms
RSA generates a key to take 0.68 seconds, visible symmetric encryption algorithm than asymmetric encryption algorithm has a very large performance advantage.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Symmetric encryption algorithm and asymmetric encryption algorithm speed comparison