Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
python-cellframe
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
6
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cellframe
python-cellframe
Commits
88cf5f1c
Commit
88cf5f1c
authored
5 years ago
by
alexey.stratulat
Browse files
Options
Downloads
Patches
Plain Diff
[*] Unit tests are fixed.
parent
6f9611b8
No related branches found
No related tags found
1 merge request
!26
Support 3689
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
test/test_b58.py
+3
-3
3 additions, 3 deletions
test/test_b58.py
test/test_b64.py
+5
-5
5 additions, 5 deletions
test/test_b64.py
test/test_oaes.py
+5
-8
5 additions, 8 deletions
test/test_oaes.py
with
13 additions
and
16 deletions
test/test_b58.py
+
3
−
3
View file @
88cf5f1c
import
lib
dap_crypto_python_module
as
crypto
import
lib
TPO
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
=
c
rypto
.
encodeBase58
(
base_in
)
crypt
=
libTPO
.
C
rypto
.
encodeBase58
(
base_in
)
print
(
"
Encrypted data:
\t
"
)
print
(
"
Encrypted data:
\t
"
)
print
(
crypt
)
print
(
crypt
)
decrypt
=
c
rypto
.
decodeBase58
(
crypt
)
decrypt
=
libTPO
.
C
rypto
.
decodeBase58
(
crypt
)
print
(
"
Decoded data:
\t
"
)
print
(
"
Decoded data:
\t
"
)
print
(
decrypt
)
print
(
decrypt
)
out_data
=
pickle
.
loads
(
decrypt
)
out_data
=
pickle
.
loads
(
decrypt
)
...
...
This diff is collapsed.
Click to expand it.
test/test_b64.py
+
5
−
5
View file @
88cf5f1c
import
lib
dap_crypto_python_module
as
crypto
import
lib
TPO
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
=
c
rypto
.
encodeBase64
(
bytes
(
s
,
"
utf-8
"
),
1
)
crypt
=
libTPO
.
C
rypto
.
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
=
c
rypto
.
decodeBase64
(
crypt
,
1
)
decrypt
=
libTPO
.
C
rypto
.
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
=
c
rypto
.
encodeBase64
(
bytes
(
u
,
"
utf-8
"
),
2
)
crypt_u
=
libTPO
.
C
rypto
.
encodeBase64
(
bytes
(
u
,
"
utf-8
"
),
libTPO
.
CryptoDataType
.
DAP_ENC_DATA_TYPE_B64_URLSAFE
()
)
decrypt_u
=
c
rypto
.
decodeBase64
(
crypt_u
)
decrypt_u
=
libTPO
.
C
rypto
.
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
:
...
...
This diff is collapsed.
Click to expand it.
test/test_oaes.py
+
5
−
8
View file @
88cf5f1c
import
lib
dap_crypto_python_module
as
crypto
import
lib
TPO
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
=
c
rypto
.
generateNewKey
(
1
,
kex_buff
,
size_kex_buff
,
seed
,
seed_size
,
32
)
key
=
libTPO
.
C
rypto
.
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
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment