Skip to content
Snippets Groups Projects
Commit 88cf5f1c authored by alexey.stratulat's avatar alexey.stratulat
Browse files

[*] Unit tests are fixed.

parent 6f9611b8
No related branches found
No related tags found
1 merge request!26Support 3689
import libdap_crypto_python_module as crypto import libTPO
import pickle import pickle
import sys import sys
...@@ -7,10 +7,10 @@ s = """Test! I will crush Base58!""" ...@@ -7,10 +7,10 @@ s = """Test! I will crush Base58!"""
base_in = pickle.dumps(s) base_in = pickle.dumps(s)
print ("Input data: "+s) print ("Input data: "+s)
print (base_in) print (base_in)
crypt = crypto.encodeBase58(base_in) crypt = libTPO.Crypto.encodeBase58(base_in)
print ("Encrypted data: \t") print ("Encrypted data: \t")
print(crypt) print(crypt)
decrypt = crypto.decodeBase58(crypt) decrypt = libTPO.Crypto.decodeBase58(crypt)
print ("Decoded data: \t") print ("Decoded data: \t")
print(decrypt) print(decrypt)
out_data = pickle.loads(decrypt) out_data = pickle.loads(decrypt)
......
import libdap_crypto_python_module as crypto import libTPO
import sys import sys
print ("Start test crypto b64") print ("Start test crypto b64")
s = "Test! I will crush Base64!" s = "Test! I will crush Base64!"
print ("Input data: "+s) print ("Input data: "+s)
crypt = crypto.encodeBase64(bytes(s, "utf-8"),1) crypt = libTPO.Crypto.encodeBase64(bytes(s, "utf-8"), libTPO.CryptoDataType.DAP_ENC_DATA_TYPE_B64())
print ("Encrypted data: \t") print ("Encrypted data: \t")
print(crypt) print(crypt)
decrypt = crypto.decodeBase64(crypt, 1) decrypt = libTPO.Crypto.decodeBase64(crypt, libTPO.CryptoDataType.DAP_ENC_DATA_TYPE_B64())
print ("Decoded data: \t") print ("Decoded data: \t")
print(decrypt) print(decrypt)
if bytes(s, "utf-8") == decrypt: if bytes(s, "utf-8") == decrypt:
...@@ -18,8 +18,8 @@ else: ...@@ -18,8 +18,8 @@ else:
print ("Test Base64 URLSAFE") print ("Test Base64 URLSAFE")
u = "http://kelvin.foundation/" u = "http://kelvin.foundation/"
crypt_u = crypto.encodeBase64(bytes(u, "utf-8"), 2) crypt_u = libTPO.Crypto.encodeBase64(bytes(u, "utf-8"), libTPO.CryptoDataType.DAP_ENC_DATA_TYPE_B64_URLSAFE())
decrypt_u = crypto.decodeBase64(crypt_u) decrypt_u = libTPO.Crypto.decodeBase64(crypt_u, libTPO.CryptoDataType.DAP_ENC_DATA_TYPE_B64_URLSAFE())
if bytes(u, "utf-8") == decrypt_u: if bytes(u, "utf-8") == decrypt_u:
print ("TEST 2. Encode/Decode base64 urlsafe done") print ("TEST 2. Encode/Decode base64 urlsafe done")
else: else:
......
import libdap_crypto_python_module as crypto import libTPO
import sys import sys
print ("Start test crypto OAES") print ("Start test crypto OAES")
s = "Test! I will crush OAES!" s = "Test! I will crush OAES!"
print ("Input data: "+s)
kex_buff = bytes("114151400014314485131FGXVGHcJFIH", "utf-8") kex_buff = bytes("114151400014314485131FGXVGHcJFIH", "utf-8")
size_kex_buff = len(kex_buff) size_kex_buff = len(kex_buff)
seed = bytes(112771128) seed = bytes(112771128)
seed_size = len(seed) seed_size = len(seed)
crypto.init() libTPO.init()
key_id = crypto.generateNewKey(1, kex_buff, size_kex_buff, seed, seed_size, 32) key = libTPO.Crypto.generateNewKey(libTPO.CryptoKeyType.DAP_ENC_KEY_TYPE_OAES(), kex_buff, size_kex_buff, seed, seed_size, 32)
source = bytes(s, "utf-8") source = bytes(s, "utf-8")
enc = crypto.encryptOAESFast(key_id, source, len(source), 2048) enc = libTPO.Crypto.encryptOAESFast(key, source, len(source), 2048)
decrypt = crypto.decryptOAESFast(key_id, enc, len(enc), 2048) decrypt = libTPO.Crypto.decryptOAESFast(key, enc, len(enc), 2048)
print (decrypt)
if bytes(s, "utf-8") == decrypt: if bytes(s, "utf-8") == decrypt:
print ("TEST 1. Encode/Decode OAES FAST done") print ("TEST 1. Encode/Decode OAES FAST done")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment