Fix a bug to support python3.x
The default type of the string is str in python3.x, if want use the type of byte ,should be delcare b'xxxx' . Change-Id: Ia03aef1f5e51403f5ef1fdba65d0fa231b8889fd
This commit is contained in:
parent
fdda55acfb
commit
d2a46346d3
@ -13,7 +13,6 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
@ -62,16 +61,16 @@ class AESCipherTestCase(unittest.TestCase):
|
|||||||
passwd = crypt.AESCipher._get_pass_from_file(pfile)
|
passwd = crypt.AESCipher._get_pass_from_file(pfile)
|
||||||
self.assertEqual(passwd, '78f40f2c57eee727a4be179049cecf89')
|
self.assertEqual(passwd, '78f40f2c57eee727a4be179049cecf89')
|
||||||
|
|
||||||
@unittest.skipIf(sys.version_info.major == 3,
|
# @unittest.skipIf(sys.version_info.major == 3,
|
||||||
'Not supported on python v 3.x')
|
# 'Not supported on python v 3.x')
|
||||||
def test_derive_key_and_iv(self):
|
def test_derive_key_and_iv(self):
|
||||||
passwd = 'ababab'
|
passwd = b'ababab'
|
||||||
salt = 'a'
|
salt = b'a'
|
||||||
ret1, ret2 = crypt.AESCipher._derive_key_and_iv(password=passwd,
|
ret1, ret2 = crypt.AESCipher._derive_key_and_iv(password=passwd,
|
||||||
salt=salt,
|
salt=salt,
|
||||||
key_length=10,
|
key_length=10,
|
||||||
iv_length=5)
|
iv_length=5)
|
||||||
expect1 = '\xb3J5\xce\xd4b\x87\xce\xe0:'
|
expect1 = b'\xb3J5\xce\xd4b\x87\xce\xe0:'
|
||||||
expect2 = '\x93\xc9\x9d\x03\x00'
|
expect2 = b'\x93\xc9\x9d\x03\x00'
|
||||||
self.assertEqual(ret1, expect1)
|
self.assertEqual(ret1, expect1)
|
||||||
self.assertEqual(ret2, expect2)
|
self.assertEqual(ret2, expect2)
|
||||||
|
Loading…
Reference in New Issue
Block a user