Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Zagir Medzhidov edited this page Feb 22, 2024 · 6 revisions

SimpleEncoder library documentation

Starting setting config:

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")

Arguments:

  • 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

Starting encode:

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())

Arguments:

  • data:str -> Data string or dict to be encoded. Required!
  • config:Config -> The configuration we set up in the last example. Optional

Starting decode:

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())

Arguments:

  • data:str -> Encoded data to be decoded. Required!
  • config:Config -> The configuration we set up in the last example. Optional

Real examples:

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!

real Example 2:

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!

Arguments b64_dict:

  • encode_values:bool -> Encode the value? Default: True
  • encode_keys: bool -> Encode a key from a value? Default: False
Morty Proxy This is a proxified and sanitized view of the page, visit original site.