RC6Encryption (version 1.0.0) | index rc6encryption.py |
This package implements RC6 encryption.
>>> rc6 = RC6Encryption(b'abcdefghijklmnop', 12, 32, 5)
>>> c = rc6.blocks_to_data(rc6.encrypt(b'abcdefghijklmnop'))
>>> rc6.blocks_to_data(rc6.decrypt(c))
b'abcdefghijklmnop'
>>>
>>> from urllib.request import urlopen, Request
>>> from json import dumps, load
>>> rc6 = RC6Encryption(b'abcdefghijklmnop')
>>> encrypt = rc6.blocks_to_data(rc6.encrypt(b'abcdefghijklmnop')).hex()
>>> encrypt
'bb05a4b6c46a24a8bf70e1e2c0a33e51'
>>> encrypt == load(urlopen(Request("https://www.lddgo.net/api/RC6?lang=en", headers={"Content-Type": "application/json;charset=UTF-8"}, data=dumps({"inputContent":"abcdefghijklmnop","model":"ECB","padding":"nopadding","inputPassword":"abcdefghijklmnop","inputIv":"","inputFormat":"string","outputFormat":"hex","charset":"UTF-8","encrypt":True}).encode())))["data"]
True
>>> encrypt = rc6.blocks_to_data(rc6.encrypt(b'abcdefghijklmnop') + rc6.encrypt(b'abcdefghijklmnop')).hex()
>>> encrypt
'bb05a4b6c46a24a8bf70e1e2c0a33e51bb05a4b6c46a24a8bf70e1e2c0a33e51'
>>> encrypt == load(urlopen(Request("https://www.lddgo.net/api/RC6?lang=en", headers={"Content-Type": "application/json;charset=UTF-8"}, data=dumps({"inputContent":"abcdefghijklmnopabcdefghijklmnop","model":"ECB","padding":"nopadding","inputPassword":"abcdefghijklmnop","inputIv":"","inputFormat":"string","outputFormat":"hex","charset":"UTF-8","encrypt":True}).encode())))["data"]
True
>>> pkcs5_7padding(b'abcdefghijklmno')
b'abcdefghijklmno\x01'
>>> remove_pkcs_padding(pkcs5_7padding(b'abcdefghijklmno')) == b'abcdefghijklmno'
True
>>> pkcs5_7padding(b'abcdefghijklm')
b'abcdefghijklm\x03\x03\x03'
>>> remove_pkcs_padding(pkcs5_7padding(b'abcdefghijklm')) == b'abcdefghijklm'
True
>>> rc6 = RC6Encryption(b'abcdefghijklm')
>>> encrypt = rc6.blocks_to_data(rc6.encrypt(pkcs5_7padding(b'abcdefghijklm'))).hex()
>>> encrypt
'c5ee3509788662a5711822d5e01eb4c0'
>>> encrypt == load(urlopen(Request("https://www.lddgo.net/api/RC6?lang=en", headers={"Content-Type": "application/json;charset=UTF-8"}, data=dumps({"inputContent":"abcdefghijklm","model":"ECB","padding":"pkcs5padding","inputPassword":"abcdefghijklm","inputIv":"","inputFormat":"string","outputFormat":"hex","charset":"UTF-8","encrypt":True}).encode())))["data"]
True
>>> rc6 = RC6Encryption(b'abcd')
>>> encrypt = rc6.data_encryption_ECB(b'abcdefghijklmnop').hex()
>>> encrypt
'78a64e37f7455f30aaf40750be1a065701bf2f308216c43c42c794285ffbf99e'
>>> encrypt == load(urlopen(Request("https://www.lddgo.net/api/RC6?lang=en", headers={"Content-Type": "application/json;charset=UTF-8"}, data=dumps({"inputContent":"abcdefghijklmnop","model":"ECB","padding":"pkcs5padding","inputPassword":"abcd","inputIv":"","inputFormat":"string","outputFormat":"hex","charset":"UTF-8","encrypt":True}).encode())))["data"]
True
>>> rc6.data_decryption_ECB(bytes.fromhex('78a64e37f7455f30aaf40750be1a065701bf2f308216c43c42c794285ffbf99e'))
b'abcdefghijklmnop'
>>> rc6 = RC6Encryption(b'abcd')
>>> iv, encrypt = rc6.data_encryption_CBC(b'abcdefghijklmnopabcdefghijklmnopabcdefghijklm', b'IVTEST')
>>> encrypt = encrypt.hex()
>>> iv
b'IVTESTIVTESTIVTE'
>>> encrypt
'8de91e69865825bbb6e1785e3b498f3a89708aaa2aff01a688cf9836bd7eea56c04fa0a14706d79bd94846e905bf070b'
>>> encrypt == load(urlopen(Request("https://www.lddgo.net/api/RC6?lang=en", headers={"Content-Type": "application/json;charset=UTF-8"}, data=dumps({"inputContent":"abcdefghijklmnopabcdefghijklmnopabcdefghijklm","model":"CBC","padding":"pkcs5padding","inputPassword":"abcd","inputIv":iv.decode('latin-1'),"inputFormat":"string","outputFormat":"hex","charset":"UTF-8","encrypt":True}).encode())))["data"]
True
>>> rc6.data_decryption_CBC(bytes.fromhex('8de91e69865825bbb6e1785e3b498f3a89708aaa2aff01a688cf9836bd7eea56c04fa0a14706d79bd94846e905bf070b'), iv)
b'abcdefghijklmnopabcdefghijklmnopabcdefghijklm'
>>>
~# rc6 mykey -s mydata -6
0wS4TwM292nGa378oBuz/w==
~# rc6 mykey -s 0wS4TwM292nGa378oBuz/w== -n base64 -d
mydata
~# rc6 mykey --no-sha256 -r 12 -s mydata -6
vzliI0irqi3tZ8fULxJ14g==
~# rc6 mykey --no-sha256 -r 12 -s vzliI0irqi3tZ8fULxJ14g== -n base64 -d
mydata
~# rc6 mykey -m CBC -I myiv -s mydata -1
6D7969766D7969766D7969766D796976BF2F024053F74FE27920DE5C274935A6
~# rc6 mykey -m CBC -d -s 6D7969766D7969766D7969766D796976BF2F024053F74FE27920DE5C274935A6 -n base16
mydata
~#
1 items passed all tests:
32 tests in RC6Encryption
32 tests in 25 items.
32 passed and 0 failed.
Test passed.
Classes | ||||||||||
|
Functions | ||
|
Data | ||
__all__ = ['RC6Encryption', 'pkcs5_7padding'] __author_email__ = 'mauricelambert434@gmail.com' __copyright__ = '\nRC6Encryption Copyright (C) 2021, 2023, 2024 ...ome to redistribute it\nunder certain conditions.\n' __description__ = 'This package implements RC6 encryption.' __license__ = 'GPL-3.0 License' __maintainer__ = 'Maurice Lambert' __maintainer_email__ = 'mauricelambert434@gmail.com' __url__ = 'https://github.com/mauricelambert/RC6Encryption' |
Author | ||
Maurice Lambert |