commit 1045b537aa0d3930b0889d4721ec499885d6d3ce
parent 274c67f9847fd1f3683bf9f0308af158d1ca4d69
Author: ThomasV <thomasv@gitorious>
Date: Tue, 3 Jun 2014 13:15:41 +0200
unit test for aes
Diffstat:
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/lib/bitcoin.py b/lib/bitcoin.py
@@ -711,21 +711,21 @@ class Test_bitcoin(unittest.TestCase):
addr_c = public_key_to_bc_address(pubkey_c)
addr_u = public_key_to_bc_address(pubkey_u)
- print "Private key ", '%064x'%pvk
+ #print "Private key ", '%064x'%pvk
eck = EC_KEY(number_to_string(pvk,_r))
- print "Compressed public key ", pubkey_c.encode('hex')
+ #print "Compressed public key ", pubkey_c.encode('hex')
enc = EC_KEY.encrypt_message(message, pubkey_c)
dec = eck.decrypt_message(enc)
assert dec == message
- print "Uncompressed public key", pubkey_u.encode('hex')
+ #print "Uncompressed public key", pubkey_u.encode('hex')
enc2 = EC_KEY.encrypt_message(message, pubkey_u)
dec2 = eck.decrypt_message(enc)
assert dec2 == message
signature = eck.sign_message(message, True, addr_c)
- print signature
+ #print signature
EC_KEY.verify_message(addr_c, signature, message)
@@ -758,6 +758,14 @@ class Test_bitcoin(unittest.TestCase):
return xpub, xprv
+ def test_aes(self):
+ s = u'\u66f4\u7a33\u5b9a\u7684\u4ea4\u6613\u5e73\u53f0'
+ self.do_test_aes(s, s)
+
+ def do_test_aes(self, s, p):
+ enc = pw_encode(s, p)
+ dec = pw_decode(enc, p)
+ assert dec == s
if __name__ == "__main__":