-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Zagir Medzhidov edited this page Feb 22, 2024
·
6 revisions
from SimpleEncoder import SimpleEncode as SE
# or
# from SimpleEncoder.SimpleEncode import Config
config = SE.config(encoding: str = "UTF-8", use_rich_print: bool = True, encode_bool:bool = False, md5_solt: str = "solt")- encoding:str -> The encoding into which the data will be encoded. Default ascii. Can be: utf-8
- use_rich_print:bool -> Use print from the rich library instead of typical raise errors
- encode_bool:bool -> Encode logical values by type False, True. No by default
- md5_solt:str -> Add a "salt" for encrypting data in md5
from SimpleEncoder import SimpleEncode as SE
# or
# from SimpleEncoder.SimpleEncode import Encode, Config
config = Config(...)
str_encode = SE.Encode(data: str | dict, config: Config = Config())- data:str -> Data string or dict to be encoded. Required!
- config:Config -> The configuration we set up in the last example. Optional
from SimpleEncoder import SimpleEncode as SE
# or
# from SimpleEncoder.SimpleEncode import Decode, Config
config = Config(...)
str_encode = SE.Decode(data: str | dict, config: Config = Config())- data:str -> Encoded data to be decoded. Required!
- config:Config -> The configuration we set up in the last example. Optional
from SimpleEncoder import SimpleEncode as SE
str_encoded = SE.Encode(data="My secret password is OneToTwo")
# or: SE.Encode("My secret password is OneToTwo")
print(str_encoded)
str_decoded = SE.Decode(data=str_encoded)
# or: SE.Decode(str_encoded)
print(str_decoded)Run it and check out the code!
from SimpleEncoder import SimpleEncode as SE
mydict = dict(username="MyName", firstname="NyFirstName", lastname="MyLastName", welcome_me=True)
dict_encoded = SE.Encode(mydict).b64_dict(encode_values: = True, encode_keys: = False)
print(dict_encoded)
dict_decoded = SE.Encode(dict_encoded).b64_dict(encode_values: = True, encode_keys: = False)Run it and check out the code!
- encode_values:bool -> Encode the value? Default: True
- encode_keys: bool -> Encode a key from a value? Default: False