コード例 #1
0
 def test_decrypt_text(self):
     password = intlist_to_bytes(self.key).decode('utf-8')
     encrypted = base64.b64encode(
         intlist_to_bytes(self.iv[:8]) +
         b'\x17\x15\x93\xab\x8d\x80V\xcdV\xe0\t\xcdo\xc2\xa5\xd8ksM\r\xe27N\xae'
     )
     decrypted = (aes_decrypt_text(encrypted, password, 16))
     self.assertEqual(decrypted, self.secret_msg)
コード例 #2
0
ファイル: test_aes.py プロジェクト: skyview059/youtube-dl
    def test_decrypt_text(self):
        password = intlist_to_bytes(self.key).decode("utf-8")
        encrypted = base64.b64encode(
            intlist_to_bytes(self.iv[:8]) + b"\x17\x15\x93\xab\x8d\x80V\xcdV\xe0\t\xcdo\xc2\xa5\xd8ksM\r\xe27N\xae"
        )
        decrypted = aes_decrypt_text(encrypted, password, 16)
        self.assertEqual(decrypted, self.secret_msg)

        password = intlist_to_bytes(self.key).decode("utf-8")
        encrypted = base64.b64encode(
            intlist_to_bytes(self.iv[:8])
            + b"\x0b\xe6\xa4\xd9z\x0e\xb8\xb9\xd0\xd4i_\x85\x1d\x99\x98_\xe5\x80\xe7.\xbf\xa5\x83"
        )
        decrypted = aes_decrypt_text(encrypted, password, 32)
        self.assertEqual(decrypted, self.secret_msg)
コード例 #3
0
ファイル: test_aes.py プロジェクト: Hobis/HB_Python
    def test_decrypt_text(self):
        password = intlist_to_bytes(self.key).decode('utf-8')
        encrypted = base64.b64encode(
            intlist_to_bytes(self.iv[:8]) +
            b'\x17\x15\x93\xab\x8d\x80V\xcdV\xe0\t\xcdo\xc2\xa5\xd8ksM\r\xe27N\xae'
        ).decode('utf-8')
        decrypted = (aes_decrypt_text(encrypted, password, 16))
        self.assertEqual(decrypted, self.secret_msg)

        password = intlist_to_bytes(self.key).decode('utf-8')
        encrypted = base64.b64encode(
            intlist_to_bytes(self.iv[:8]) +
            b'\x0b\xe6\xa4\xd9z\x0e\xb8\xb9\xd0\xd4i_\x85\x1d\x99\x98_\xe5\x80\xe7.\xbf\xa5\x83'
        ).decode('utf-8')
        decrypted = (aes_decrypt_text(encrypted, password, 32))
        self.assertEqual(decrypted, self.secret_msg)
コード例 #4
0
 def test_cbc_encrypt(self):
     data = bytes_to_intlist(self.secret_msg)
     encrypted = intlist_to_bytes(aes_cbc_encrypt(data, self.key, self.iv))
     self.assertEqual(
         encrypted,
         b"\x97\x92+\xe5\x0b\xc3\x18\x91ky9m&\xb3\xb5@\xe6'\xc2\x96.\xc8u\x88\xab9-[\x9e|\xf1\xcd"
     )
コード例 #5
0
 def test_cbc_decrypt(self):
     data = bytes_to_intlist(
         b"\x97\x92+\xe5\x0b\xc3\x18\x91ky9m&\xb3\xb5@\xe6'\xc2\x96.\xc8u\x88\xab9-[\x9e|\xf1\xcd"
     )
     decrypted = intlist_to_bytes(aes_cbc_decrypt(data, self.key, self.iv))
     self.assertEqual(decrypted.rstrip(b'\x08'), self.secret_msg)
コード例 #6
0
 def test_encrypt(self):
     msg = b'message'
     key = list(range(16))
     encrypted = aes_encrypt(bytes_to_intlist(msg), key)
     decrypted = intlist_to_bytes(aes_decrypt(encrypted, key))
     self.assertEqual(decrypted, msg)
コード例 #7
0
def hex_str(int_list):
	return codecs.encode(intlist_to_bytes(int_list), 'hex')
コード例 #8
0
ファイル: test_utils.py プロジェクト: Kyad/youtube-dl
 def test_intlist_to_bytes(self):
     self.assertEqual(
         intlist_to_bytes([0, 1, 127, 128, 255]),
         b'\x00\x01\x7f\x80\xff')
コード例 #9
0
 def test_intlist_to_bytes(self):
     self.assertEqual(intlist_to_bytes([0, 1, 127, 128, 255]),
                      b'\x00\x01\x7f\x80\xff')
コード例 #10
0
def hex_str(int_list):
    return codecs.encode(intlist_to_bytes(int_list), 'hex')