API

The below shows all the available functions and variables within this module.

Ciphers

A dictionary object variable which contains a curated list of ascii or utf-8 characters. This object can be mutated into whatever character structure you want by importing it and change every character.

By default it comes with 225 characters. Which includes alphanumeric and special characters

import mistyfy as ms

ms.ciphers = {} # denoting new characters which can be mutated.
mistyfy.generator(cipher, start=70, stop=1000, fmt=True)

Generates a random unique number for each characters.

from mistyfy import ciphers, generator
import json
import os

if not os.path.exists('../data/config.json'):
    gen = generator(ciphers, -400, 13931283)
    json.dump(gen, open('../data/config.json', mode='w+',
             encoding='utf-8'), indent=4, sort=True)


if __name__ == "__main__":
     if os.path.isfile('../data/config.json'):
        data = json.dumps(json.load(open('../data/config.json')))
        print(data)

New in version 2.0.0.

fmt argument - Exports the cipher format in string if true,

dictionary if false.

Parameters:
  • cipher (dict) – A pseudo series of text

  • start (int) – An integer to begin our randomization from

  • stop (int) – An integer to our stop randomization

  • fmt (bool) – Exports the cipher format in string if true, dictionary if false.

Returns:

A dictionary having unique numbers for your cipher

Return type:

str | dict

mistyfy.encode(data, secret, cipher=None, expire=3600, **kwargs)

Encrypts a given string and send an output.

from mistyfy import encode, ciphers, generator
import os

gn = generator(ciphers, -400, 138192812)

# create any secret key, easier if you use os.urandom(n)
secret = b'somesecretkey'
# secret = os.urandom(16)
a = "This is a secret message or password"
b = encode(a, secret, gn)
# output is a string base64, encoded with a signature,
# and mistyfied with the cipher.
# eyJtaXN0eWZ5IjogWzQ5Nxxxxxx...

The generator function helps to create a cipher. Ciphers is a dictionary containing ascii or utf-8 characters, you can change this at will using the generator function to create your own unique cipher. The first argument is the cipher block, second & third argument is the start and stop counter.

New in version 2.0.0.

expire argument - The number of seconds an encoded data can last for. This timestamp is in UTC. By default it is set to 1 hour from the initial encoded time.

Parameters:
  • data (str) – a string value

  • secret (str) – A secret key.

  • cipher (str | dict | None) – a pseudo randomizer

  • expire (int) – The number of seconds an encoded data can last for.

  • kwargs (Any) –

    Additional parameters you can add to hashlib

    options

    auth_size: integer - If used in encode, the same size must be used for decode, taken from arguments from blake2b

    key: Union[bytes, bytearray, memoryview,

    array, mmap, mmap] = …,

    salt: Union[bytes, bytearray, memoryview,

    array, mmap, mmap] = …,

    person: Union[bytes, bytearray, memoryview,

    array, mmap, mmap] = …,

    fanout: int = …,

    depth: int = …,

    leaf_size: int = …,

    node_offset: int = …,

    node_depth: int = …,

    inner_size: int = …,

    last_node: bool = …,

    usedforsecurity: bool = …

Returns:

string with signature and the data in bs64(when decrypted returns list of numbers)

Return type:

str

mistyfy.decode(data, secret, cipher=None, **kwargs)

Decrypts a data and sends output as string. Usually the original form of an encoded data.

from mistyfy import encode, decode, ciphers, generator
import os

gn = generator(ciphers, -400, 138192812)
secret = os.urandom(16)
a = "This is a secret message or password"
b = encode(a, secret, gn)
# output is a string
# eyJtaXN0eWZ5IjogWzQ5Nxxxxxx...
# decode the data with the below
c = decode(b, secret, gn)
# Output:
# This is a secret message or password
Parameters:
  • data (str) – A strings of encoded data

  • secret (str) – A super secret key

  • cipher (str | None) – a pseudo randomizer

  • kwargs (Any) –

    Additional parameters you can add to hashlib

    options

    auth_size: integer - If used in encode, the same size must be used for decode taken from arguments from blake2b

    key: Union[bytes, bytearray, memoryview,

    array, mmap, mmap] = …,

    salt: Union[bytes, bytearray, memoryview,

    array, mmap, mmap] = …,

    person: Union[bytes, bytearray, memoryview,

    array, mmap, mmap] = …,

    fanout: int = …,

    depth: int = …,

    leaf_size: int = …,

    node_offset: int = …,

    node_depth: int = …,

    inner_size: int = …,

    last_node: bool = …,

    usedforsecurity: bool = …

Returns:

String of the decrypted data.

Return type:

str

mistyfy.signs(data, secret, auth_size=16, **kwargs)

Using blake2b, a set of encryption algorithms to sign our data.

from mistyfy import signs

secret = "somesecretstuff"
password = "mypasswordstuff"

code = signs(password, secret)
# result
# c2342328dhsjxxxxxx
Parameters:
  • data (Any) – Any data value,

  • secret (str) – A secret key

  • auth_size – digest size key

Returns:

strings of encrypted hash.

Return type:

str

mistyfy.verify_signs(data, signature, **kwargs)

Verify that a signed byte is indeed the right hash.

from mistyfy import verify_signs, signs

secret = "somesecretstuff"
password = "mypasswordstuff"
code = signs(password, secret)

reveal = verify_signs(password, code, secret=secret)
# result
# mypasswordstuff
Parameters:
  • data (Any) – Any encrypted data

  • signature (str) – A signed hash

  • kwargs

    Additional arguments to use

    auth_size: Authenticate key passed to signs function.

    secret: A secret key passed to signs function You can also use the same arguments applicable to blake2b and they are passed to the signs function.

Returns:

A boolean value to confirm True of False of signed hash.

Return type:

bool