Пример #1
0
    def test_bytes_to_key(self):
        password = '******'
        cipher = IdecdsaCipher()

        assert ('^\xbe"\x94\xec\xd0\xe0\xf0\x8e\xab',
                'v\x90\xd2\xa6\xeei&\xae\\\xc8T\xe3kk\xdf\xca6hH\xde') == \
            cipher.EVP_BytesToKey(password, 10, 20)
Пример #2
0
    def test_pad_unpad(self):
        data = '0123456789abcdef'

        assert data == IdecdsaCipher.unpad(IdecdsaCipher.pad(data))

        data = b'0123456789abcdef'

        assert data == IdecdsaCipher.unpad(IdecdsaCipher.pad(data))
Пример #3
0
    def test_init(self):
        password = '******'
        data = ('c7d360e0d7d6820ea8d33cc7ad81bf9d'
                '04c2f9c793f21cbf0a4a004350346ab8')

        cipher = IdecdsaCipher()

        assert cipher.simpleDecrypt(password,
                                    cipher.simpleEncrypt(password,
                                                         data)) == data
Пример #4
0
    def test_encrypt_decrypt(self):
        password = '******'
        data = ('c7d360e0d7d6820ea8d33cc7ad81bf9d'
                '04c2f9c793f21cbf0a4a004350346ab8')

        cipher = IdecdsaCipher()

        assert cipher.simpleDecrypt(
            password, cipher.simpleEncrypt(password, data)) == \
            data

        bytes_data = 'testpassword'.encode('utf-8')
        assert cipher.simpleDecrypt(
            password, cipher.simpleEncrypt(password, bytes_data)) == \
            bytes_data