Skip to content

Latest commit

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Fast-Cryptography

Apache License 2.0PyPI version

Fast-Cryptography - This is a library with cryptographic operations, including asymmetric and symmetric encryption, signatures, and hashes. We use modern cryptographic technologies!. This module was created for lazy developers.

Developer: Alexx-coder or alexx (GitHub)

Version: 0.1.4

License: Apache License 2.0

Fast-Cryptography on Github

Fast-Cryptography on PyPi

Install:

pip install fast-cryptography

Acknowledgements

This project uses:


Working with functions

Asymmetric

There are 3 modules in total: RSA, ECC, Ed25519

RSA

  • There are 3 functions in total: rsa_gen_keys_pem(), rsa_encrypt(), rsa_decrypt()

  • How import:

fromfast_cryptography.algorithms.asymmetric.rsaimportrsa_encrypt, rsa_decrypt, rsa_gen_keys_pem# Import functions
  • Or:
fromfast_cryptography.algorithms.asymmetricimportrsa# Import module
  • How it works gen_keys_pem():
Stages
Generation
Serialization
Print your keys: private and public
  • And in code:
fromfast_cryptography.algorithms.asymmetric.rsaimportrsa_gen_keys_pemkeys=rsa_gen_keys_pem() # We do not specify attributesprint(keys) 
  • Now how it works rsa_encrypt();
Stages
Load public key
Encrypting
Print: encrypted message in the format Base64
  • And in code:
fromfast_cryptography.algorithms.asymmetric.rsaimportrsa_encrypt, rsa_gen_keys_pemkeys=rsa_gen_keys_pem()
public_pem=keys['public']
encryption=rsa_encrypt("Your message", public_pem) # Specify the message and your public key (preferably as a variable)print(encryption)
  • And at the end how it works rsa_decrypt():
Stages
Load private key
Decrypting
Print: message
  • And in code:
fromfast_cryptography.algorithms.asymmetric.rsaimportrsa_decrypt, rsa_gen_keys_pem, rsa_encryptkeys=rsa_gen_keys_pem()
private_pem=keys['private']
public_pem=keys['public']
encryption=rsa_encrypt("Your message", public_pem)
decryption=rsa_decrypt(encryption, private_pem) # Specify the encrypted message and your private key (preferably as a variable)print(decryption)

ECC

  • There are 3 functions in total: ecc_gen_keys_pem(), ecc_sign(), ecc_verify()

  • How import:

fromfast_cryptography.algorithms.asymmetric.eccimportecc_gen_keys_pem, ecc_sign, ecc_verify
  • Or:
fromfast_cryptography.algorithms.asymmetricimportecc
  • How it works ecc_gen_keys_pem():
Stages
Generation
Serialization
Print your keys: private and public
  • And in code:
fromfast_cryptography.algorithms.asymmetric.eccimportecc_gen_keys_pemkeys=ecc_gen_keys_pem() # We do not specify attributesprint(keys)
  • Now how it works ecc_sign:
Stages
Load private key
Signing up
Print: signature in formate Base64
  • And in code:
fromfast_cryptography.algorithms.asymmetric.eccimportecc_gen_keys_pem, ecc_signkeys=ecc_gen_keys_pem() private_pem=keys['private']
signature=ecc_sign("Your message", private_pem) # Specify the message and your private key (preferably as a variable)print(signature)
  • And at the end how it works ecc_verify():
Stages
Load public key
Verifying signature
Print: True or False
  • And in code:
fromfast_cryptography.algorithms.asymmetric.eccimportecc_gen_keys_pem, ecc_sign, ecc_verifykeys=ecc_gen_keys_pem()
private_pem=keys['private']
public_pem=keys['public']
siganture=ecc_sign("Your message", private_pem)
verify=ecc_verify("Your message", signature, public_pem)
print(verify)

Ed25519

  • There are 3 functions in total: ed25519_gen_keys_pem(), ed25519_sign(), ed25519_verify()

  • How import:

fromfast_cryptography.algorithms.asymmetric.ed25519imported25519_gen_keys_pem, ed25519_sign, ed25519_verify
  • Or:
fromfast_cryptography.algorithms.asymmetricimported25519
  • How it works ed25519_gen_keys_pem()
Stages
Generation
Serialization
Print your keys: private and public
  • And in code:
fromfast_cryptography.algorithms.asymmetric.ed25519imported25519_gen_keys_pemkeys=ed25519_gen_keys_pem() # We do not specify attributesprint(keys)
  • Now how it works ed25519_sign():
Stages
Load private key
Signing up
Print: signature in format Base64
  • And in code:
fromfast_cryptography.algorithms.asymmetric.ed25519imported25519_gen_keys_pem, ed25519_signkeys=ed25519_gen_keys_pem()
private_pem=keys['private']
signature=sign("Your message", private_pem) # Specify the message and your private key (preferably as a variable)
  • And at the end how it works ed25519_verify():
Stages
Load public key
Verifying signature
Print: True or False
  • And in code:
fromfast_cryptography.algorithms.asymmetric.ed25519imported25519_gen_keys_pem, ed25519_sign, ed25519_verifykeys=ed25519_gen_keys_pem()
private_pem=keys['private']
public_pem=keys['public']
signature=ed25519_sign("Your message", private_pem)
verify=ed25519_verify("Your message", signature, public_pem)
print(verify)

Symmetric

There are 3 modules in total: Fernet, AES, ChaCha20

Fernet

  • There are 3 functions in total: fernet_generate_key(), fernet_encrypt(), fernet_decrypt()

  • How import:

fromfast_cryptography.algorithms.symmetric.fernetimportfernet_generate_key, fernet_encrypt, fernet_decrypt
  • Or:
fromfast_cryptography.algorithms.symmetricimportfernet
  • How it works fernet_generate_key()
Stages
Generation
Decode in UTF-8
Print your key
  • And in code:
fromfast_cryptography.algorithms.symmetric.fernetimportfernet_generate_keykey=fernet_generate_key() # We do not specify attributesprint(key)
  • Now how it works fernet_encrypt():
Stages
Encode your key for cipher
Encrypting
Print: your encrypted message in UTF-8
  • And in code:
fromfast_cryptography.algorithms.symmetric.fernetfernet_generate_key, fernet_encryptkey=fernet_generate_key()
encrypt=fernet_encrypt("Your message", key) # Specify the message and your key (preferably as a variable)print(encrypt)
  • And at the end how it works fernet_decrypt():
Stages
Encode your key for cipher
Decrypting
Print: your decrypted message
  • And in code:
fromfast_cryptography.algorithms.symmetric.fernetimportfernet_generate_key, fernet_encrypt, fernet_decryptkey=fernet_generate_key()
encrypt=fernet_encrypt("Your message", key)
decrypted=fernet_decrypt(encrypt, key) # Specify the encrypted message and your key (preferably as a variable)

AES-CBC (without authentication)

  • There are 3 functions in total: aes_generate_key(), aes_encrypt(), aes_decrypt()

  • How import:

fromfast_cryptography.algorithms.symmetric.aes_cbcimportaes_generate_key, aes_encrypt, aes_decrypt
  • Or:
fromfast_cryptography.algorithms.symmetricimportaes_cbc
  • How it works aes_generate_key()
Stages
Generation
Decode in base64
Print your key
  • And in code:
fromfast_cryptography.algorithms.symmetric.aes_cbcimportaes_generate_keysize=# 16 (AES-128), 24 (AES-192) or 32 (AES-256)key=aes_generate_key(size) # We do specify attribute key size (16, 24 or 32)print(key)
  • Now how it works aes_encrypt():
Stages
Encode message to bytes
Decode key from Base64
Generate random IV (16 bytes)
Create AES cipher in CBC mode with IV
Create PKCS7 padder (block size 16)
Pad the message
Encrypt padded message
Combine IV + ciphertext
Encode result to Base64
  • And in code:
fromfast_cryptography.algorithms.symmetric.aes_cbcimportaes_generate_key, aes_encryptsize=# 16 (AES-128), 24 (AES-192) or 32 (AES-256)key=aes_generate_key(size)
encrypt=aes_encrypt("Your message", key) # Specify the message and your key (preferably as a variable)print(encrypt)
  • And at the end how it works aes_decrypt():
Stages
Decode encrypted data from Base64
Decode key from Base64
Extract IV (first 16 bytes)
Extract ciphertext (remaining bytes)
Create AES cipher in CBC mode with IV
Decrypt ciphertext
Unpad decrypted data (PKCS7)
Decode bytes to string
  • And in code:
fromfast_cryptography.algorithms.symmetric.aes_cbcimportaes_generate_key, aes_encrypt, aes_decryptsize=# 16 (AES-128), 24 (AES-192) or 32 (AES-256)key=aes_generate_key(size)
encrypt=aes_encrypt("Your message", key) decrypted=aes_decrypt(encrypted, key) # Specify the encrypted message and your key (preferably as a variable)

AES-GCM (with authentication)

  • There are 3 functions in total: aes_gcm_generate_key(), aes_gcm_encrypt(), aes_gcm_decrypt()
  • How import:
fromfast_cryptography.algorithms.symmetric.aes_gcmimportaes_gcm_generate_key, aes_gcm_encrypt, aes_gcm_decrypt
  • Or:
fromfast_cryptography.algorithms.symmetricimportaes_gcm
  • How it works aes_gcm_generate_key()
Stages
Generation
Decode in base64
Print your key
  • And in code:
fromfast_cryptography.algorithms.symmetric.aes_gcmimportaes_gcm_generate_keysize=# 16 (AES-128), 24 (AES-192) or 32 (AES-256)key=aes_gcm_generate_key(size) # We do specify attribute key size (16, 24 or 32)print(key)
  • Now how it works aes_gcm_encrypt():
Stages
Encode message to bytes
Decode key from Base64
Generate random nonce (12 bytes)
Create AESGCM cipher with key
Encrypt message (authentication built-in)
Combine nonce + ciphertext
Encode result to Base64
  • And in code:
fromfast_cryptography.algorithms.symmetric.aes_gcmimportaes_generate_key, aes_encryptsize=128# or 256key=aes_generate_key(size)
encrypted=aes_encrypt("Your message", key)
print(encrypted)
  • And at the end how it works aes_decrypt():
Stages
Decode encrypted data from Base64
Decode key from Base64
Extract nonce (first 12 bytes)
Extract ciphertext (remaining bytes)
Create AESGCM cipher with key
Decrypt ciphertext (authentication verified)
Decode bytes to string
  • And in code:
fromfast_cryptography.algorithms.symmetric.aes_gcmimportaes_generate_key, aes_encrypt, aes_decryptsize=128# or 256key=aes_generate_key(size)
encrypted=aes_encrypt("Your message", key)
decrypted=aes_decrypt(encrypted, key)

ChaCha20-Poly1305

  • There are 3 functions in total: chacha20_poly1305_generate_key(), chacha20_poly1305_encrypt(), chacha20_poly1305_decrypt()

  • How import:

fromfast_cryptography.algorithms.symmetric.chacha20_poly1305importchacha20_poly1305_generate_key, chacha20_poly1305_encrypt, chacha20_poly1305_decrypt
  • Or:
fromfast_cryptography.algorithms.symmetricimportchacha20_poly1305
  • How it works chacha20_poly1305_generate_key():
Stages
Generation
Decode in base64
Print your key
  • And in code
fromfast_cryptography.algorithms.symmetric.chacha20importchacha20_generate_keykey=chacha20_generate_key() print(key)
  • Now how it works chacha20_poly1305_encrypt():
Stages
Encode message to bytes
Decode key from Base64
Generate random nonce (12 bytes)
Create ChaCha20Poly1305 cipher with key
Encrypt message (authentication built-in)
Combine nonce + ciphertext
Encode result to Base64
  • And in code:
fromfast_cryptography.algorithms.symmetric.chacha20_poly1305importchacha20_poly1305_generate_key, chacha20_poly1305_encryptkey=chacha_generate_key()
encrypted=chacha_encrypt("Your message", key)
print(encrypted)
  • And at the end how it works chacha_decrypt():
Stages
Decode encrypted data from Base64
Decode key from Base64
Extract nonce (first 12 bytes)
Extract ciphertext (remaining bytes)
Create ChaCha20Poly1305 cipher with key
Decrypt ciphertext (authentication verified)
Decode bytes to string
  • And in code:
fromfast_cryptography.algorithms.symmetric.chacha20_poly1305importchacha20_poly1305_generate_key, chacha20_poly1305_encrypt, chacha20_poly1305_decryptkey=chacha_generate_key()
encrypted=chacha_encrypt("Your message", key)
decrypted=chacha_decrypt(encrypted, key)

ChaCha20

  • There are 3 functions in total: chacha20_generate_key(), chacha20_encrypt(), chacha20_decrypt()

  • How import:

fromfast_cryptography.algorithms.symmetric.chacha20importchacha20_generate_key, chacha20_encrypt, chacha20_decrypt
  • Or:
fromfast_cryptography.algorithms.symmetricimportchacha20
  • How it works chacha20_generate_key():
Stages
Generation
Decode in base64
Print your key
  • And in code
fromfast_cryptography.algorithms.symmetric.chacha20importchacha20_generate_keykey=chacha20_generate_key() print(key)
  • Now how it works chacha20_encrypt():
Stages
Encode message to bytes
Decode key from Base64
Generate random nonce (16 bytes)
Create ChaCha20 cipher with nonce
Encrypt message
Combine nonce + ciphertext
Encode result to Base64
  • And in code:
fromfast_cryptography.algorithms.symmetric.chacha20importchacha20_generate_key, chacha20_encryptkey=chacha20_generate_key()
encrypt=chacha20_encrypt("Your message", key) # Specify the message and your key (preferably as a variable)print(encrypt)
  • And at the end how it works chacha20_decrypt():
Stages
Decode encrypted data from Base64
Decode key from Base64
Extract nonce (first 16 bytes)
Extract ciphertext (remaining bytes)
Create ChaCha20 cipher with nonce
Decrypt ciphertext
Decode bytes to string
  • And in code:
fromfast_cryptography.algorithms.symmetric.chacha20importchacha20_generate_key, chacha20_encrypt, chacha20_decryptkey=chacha20_generate_key()
encrypt=chacha20_encrypt("Your message", key) decrypted=chacha20_decrypt(encrypted, key) # Specify the encrypted message and your key (preferably as a variable)

Hashes

We are use the best hashes and the worst hashes in this libraly

Warning: For security use size salt: 32 Bytes. But can use 16-64 Bytes. GoodLuck!

  • All hashes have the same stages.

  • How they works:

Stages
Generation salt (bytes)
Generation hash: your message + salt + encode
Print: hash
  • And in code (all) :
fromfast_cryptography.algorithms.hashes.md4importhash_md4fromfast_cryptography.algorithms.hashes.md5importhash_md5fromfast_cryptography.algorithms.hashes.ripemd160importhash_ripemd160fromfast_cryptography.algorithms.hashes.sha1importhash_sha1fromfast_cryptography.algorithms.hashes.sha224importhash_sha224fromfast_cryptography.algorithms.hashes.sha256importhash_sha256fromfast_cryptography.algorithms.hashes.sha384importhash_sha384fromfast_cryptography.algorithms.hashes.sha512importhash_sha512fromfast_cryptography.algorithms.hashes.sha3_224importhash_sha3_224fromfast_cryptography.algorithms.hashes.sha3_256importhash_sha3_256fromfast_cryptography.algorithms.hashes.sha3_384importhash_sha3_384fromfast_cryptography.algorithms.hashes.sha3_512importhash_sha3_512fromfast_cryptography.algorithms.hashes.blake2bimporthash_blake2bfromfast_cryptography.algorithms.hashes.blake2simporthash_blake2smessage='Your message'size=32# Список хэш-функцийhashes= [
hash_md4, hash_md5, hash_ripemd160,
hash_sha1, hash_sha224, hash_sha256,
hash_sha384, hash_sha512,
hash_sha3_224, hash_sha3_256, hash_sha3_384, hash_sha3_512,
hash_blake2b, hash_blake2s
]
print("=== Testing hashes ===\n")
forhinhashes:
hash_val, salt=h(message, size)
print(f"{h.__name__} | {hash_val}... | Salt: {salt}...")

Cryptorandom

Here 7 modules: byte, hex_bytes, salt, nonce, iv, choice, randint

Byte

  • How import:
fromfast_cryptography.algorithms.cryptorandom.byteimportbytes_token, bytes_urandom, bytes_uuid, bytes_random
  • Or:
fromfast_cryptography.algorithms.cryptorandomimportbyte
  • How they works:
Stages
Generation bytes use definite algorithm
Print: bytes
  • Algorithms:
Algorithms on Python
Secrets (Module name): bytes_token
OS (Module name): bytes_urandom
UUID 4 (Module name - uuid): bytes_uuid
Random (Module name: bytes_random)
  • And in code:
fromfast_cryptography.algorithms.cryptorandom.byteimportbytes_token, bytes_urandom, bytes_uuid, bytes_randomprint(bytes_token(32)) # I'm use 32 bytes. But can you use 16-64 bytes. 32 bytes it's safeprint(bytes_urandom(32))
print(bytes_uuid(32))
print(bytes_random(32))
# WARNINGS!!! Don't forget to specify the quantity of bytes.

Hex_bytes

  • How import:
fromfast_cryptography.algorithms.cryptorandom.hex_bytesimporthex_token, hex_token_bytes, encode_hex, decode_hex, hex2text, text2hex, is_valid_hex
  • Or:
fromfast_cryptography.algorithms.cryptorandomimporthex_bytes
  • In code:
ffromfast_cryptography.algorithms.cryptorandom.hex_bytesimporthex_token, hex_token_bytes, encode_hex, decode_hex, hex2text, text2hex, is_valid_hexprint(hex_token(16)) # Don't forget to specify the quantity of bytes.print(hex_token_bytes(16))
data=b"Hello, bro!"hex_str=encode_hex(data)
print(hex_str)
decoded=decode_hex(hex_str)
print(decoded)
print(hex2text("48656c6c6f"))
print(text2hex("Hello"))
print(is_valid_hex("48656c6c6f"))
print(is_valid_hex("GGG"))

Salt

Size salt in bytes: 16-64

  • How import:
fromfast_cryptography.algorithms.cryptorandom.saltimportsalt_gen, salt_gen_hex
  • Or:
fromfast_cryptography.algorithms.cryptorandomimportsalt
  • How it works salt_gen():
Stages
Generation bytes
Print: salt
  • And how it works salt_gen_hex():
Stages
Generation bytes
Print: salt in format hex
  • In code:
fromfast_cryptography.algorithms.cryptorandom.saltimportsalt_gen, salt_gen_hexprint(salt_gen(32)) # Don't forget to specify the quantity of bytes.print(salt_gen_hex(32))

Nonce

Size nonce in bytes: 12-16

  • How import:
fromfast_cryptography.algorithms.cryptorandom.nonceimportnonce_gen, nonce_gen_hex
  • Or:
fromfast_cryptography.algorithms.cryptorandomimportnonce
  • How it works nonce_gen():
Stages
Generation bytes
Print: nonce
  • And how it works nonce_gen_hex():
Stages
Generation bytes
Print: nonce in format hex
  • In code:
fromfast_cryptography.algorithms.cryptorandom.nonceimportnonce_gen, nonce_gen_hexprint(nonce_gen()) # You can choose not to specify a size nonce (only 16), or you can specify (12-16)print(nonce_gen_hex())

IV

Size iv in bytes: only 16

  • How import:
fromfast_cryptography.algorithms.cryptorandom.ivimportiv_gen, iv_gen_hex
  • Or:
fromfast_cryptography.algorithms.cryptorandomimportiv
  • How it works iv_gen():
Stages
Generation bytes
Print: iv
  • And how it works iv_gen_hex():
Stages
Generation bytes
Print: iv in format hex
  • In code:
fromfast_cryptography.algorithms.cryptorandom.nonceimportiv_gen, iv_gen_hexprint(iv_gen()) # You don't need to specify the size iv, size iv only 16 bytesprint(iv_gen_hex())

Choice

  • How import:
fromfast_cryptography.algorithms.cryptorandom.choiceimportcrypto_choice, random_choice, random_choices, scientific_choice
  • Or:
fromfast_cryptography.algorithms.cryptorandomimportchoice
  • How it works:
Stages
Selects using its own algorithm
Print: what did he choose
  • In code:
fromfast_cryptography.algorithms.cryptorandom.choiceimportcrypto_choice, random_choice, random_choices, scientific_choicechoice= ['1', '2'] # I'm showing you on the example, but you create mine# Warning: don't forget to specify the variable (choice for example)print(crypto_choice(choice))
print(random_choice(choice))
print(random_choices(choice))
print(scientific_choice(choice))

Randint

  • How import:
fromfast_cryptography.algorithms.cryptorandom.randintimportcrypto_randbelow, crypto_randint, random_randint
  • Or:
fromfast_cryptography,algorithms.cryptorandomimportrandint
  • How it works crypto_randbelow:
Stages
Selects a random (use cryptography) number from number 0 up to a number (selected by you)
Print: selected number
  • And how it works crypto_randint and random_randint:

| Stages | | Selects a random (use cryptography or not) number (selected by you) up to a number (selected by you) | | Print: selected number |

  • And in code:
fromfast_cryptography.algorithms.cryptorandom.randintimportcrypto_randbelow, crypto_randint, random_randintnumber_one=21# For example (variable for all function)number_two=1221# For example (variable for crypto_randint and random_randint)# Warning: don't forget to specify the variableprint(crypto_randbelow(number_one)) #print(crypto_randint(number_one, number_two))
print(random_randint(number_one, number_two))

Encoding

Here 7 modules: base64, base58, base45, base32, base16, base85, baseA85

Base64

  • How import:
fromfast_cryptography.algorithms.encoding.base64importbase64_encode, base64_decode, base64_url_encode, base64_url_decode, is_valid_base64
  • Or:
fromfast_cryptography.algorithms.encodingimportbase64
  • How it works: base64_encode and base64_decode:
Stages
Encoding your message or decoding your message in formate base64
Print: encoded message in formate base64 or decoded message
  • How it works base64_url_encode and base64_url_decode:
Stages
Encoding your message for url or decoding your message in formate base64 for url
Print: encoded message in formate base64 for url or decoded message
  • And how it works is_valid_base64:
Stages
Checks if the text is valid in formate base64
Print: return True or False
  • And in code:
fromfast_cryptography.algorithms.encoding.base64importbase64_encode, base64_decode, base64_url_encode, base64_url_decode, is_valid_base64text=b'Python'# For example# Base64encoded=base64_encode(text)
print(encoded)
decoded=base64_decode(encoded)
print(encode)
# Base64 for urlencoded_url=base64_url_encode(text)
print(encoded_url)
decoded_url=base64_url_decode(encoded_url)
print(decoded)
# Is valid print(is_valid_base64(encoded)) # True or False# Orreturnis_valid_base64(encoded)

Base58

  • How import:
fromfast_cryptography.algorithms.encoding.base58importbase58_encode, base58_decode, is_valid_base58
  • Or:
fromfast_cryptography.algorithms.encodingimportbase58
  • How it works base58_encode:
Stages
Encoding your message in formate Base58
Print: encoded your message in formate Base58
  • How it works base58_decode:
Stages
Decoding message (in formate base58) in text
Print: decoded message
  • And how it works is_valid_base58:
Stages
Checks if the text is valid in formate base58
Print: return True or False
  • And in code:
fromfast_cryptography.algorithms.encoding.base64importbase58_encode, base58_decode, is_valid_base58text=b'Python'# Base58encoded=base58_encode(text)
print(encoded)
decoded=base58_decode(encoded)
print(decoded)
# Is validprint(is_valid_base58(encoded)) # True or False# Orreturnis_valid_base58(encodedd)

Base45

  • How import:
fromfast_cryptography.algorithms.encoding.base45importbase45_encode, base45_decode, is_valid_base45
  • Or:
fromfast_cryptography.algorithms.encodingimportbase45
  • How it works base45_encode:
Stages
Encoding your message in formate Base45
Print: encoded your message in formate Base45
  • How it works base45_decode:
Stages
Decoding message (in formate base45) in text
Print: decoded message
  • And how it works is_valid_base45:
Stages
Checks if the text is valid in formate base45
Print: return True or False
  • And in code:
fromfast_cryptography.algorithms.encoding.base45importbase45_encode, base45_decode, is_valid_base45text=b'Python'# Base58encoded=base45_encode(text)
print(encoded)
decoded=base45_decode(encoded)
print(decoded)
# Is validprint(is_valid_base45(encoded)) # True or False# Orreturnis_valid_base45(encodedd)

Base32

  • How import:
fromfast_cryptography.algorithms.encoding.base32importbase32_encode, base32_decode, is_valid_base32
  • Or:
fromfast_cryptography.algorithms.encodingimportbase32
  • How it works base32_encode:
Stages
Encoding your message in formate Base32
Print: encoded your message in formate Base32
  • How it works base32_decode:
Stages
Decoding message (in formate base32) in text
Print: decoded message
  • And how it works is_valid_base32:
Stages
Checks if the text is valid in formate base32
Print: return True or False
  • And in code:
fromfast_cryptography.algorithms.encoding.base32importbase32_encode, base32_decode, is_valid_base32text=b'Python'# Base58encoded=base32_encode(text)
print(encoded)
decoded=base32_decode(encoded)
print(decoded)
# Is validprint(is_valid_base32(encoded)) # True or False# Orreturnis_valid_base32(encodedd)

Base16

  • How import:
fromfast_cryptography.algorithms.encoding.base16importbase16_encode, base16_decode, is_valid_base16
  • Or:
fromfast_cryptography.algorithms.encodingimportbase16
  • How it works base16_encode:
Stages
Encoding your message in formate Base16
Print: encoded your message in formate Base16
  • How it works base16_decode:
Stages
Decoding message (in formate base16) in text
Print: decoded message
  • And how it works is_valid_base16:
Stages
Checks if the text is valid in formate base16
Print: return True or False
  • And in code:
fromfast_cryptography.algorithms.encoding.base45importbase16_encode, base16_decode, is_valid_base16text=b'Python'# Base58encoded=base16_encode(text)
print(encoded)
decoded=base16_decode(encoded)
print(decoded)
# Is validprint(is_valid_base16(encoded)) # True or False# Orreturnis_valid_base16(encodedd)

Base85

  • How import:
fromfast_cryptography.algorithms.encoding.base85importbase85_encode, base85_decode, is_valid_base85
  • Or:
fromfast_cryptography.algorithms.encodingimportbase85
  • How it works base85_encode:
Stages
Encoding your message in formate Base85
Print: encoded your message in formate Base85
  • How it works base85_decode:
Stages
Decoding message (in formate base85) in text
Print: decoded message
  • And how it works is_valid_base85:
Stages
Checks if the text is valid in formate base85
Print: return True or False
  • And in code:
fromfast_cryptography.algorithms.encoding.base85importbase85_encode, base85_decode, is_valid_base85text=b'Python'# Base58encoded=base85_encode(text)
print(encoded)
decoded=base85_decode(encoded)
print(decoded)
# Is validprint(is_valid_base85(encoded)) # True or False# Orreturnis_valid_base85(encodedd)

BaseA85

  • How import:
fromfast_cryptography.algorithms.encoding.baseA85importbaseA85_encode, baseA85_decode, is_valid_baseA85
  • Or:
fromfast_cryptography.algorithms.encodingimportbaseA85
  • How it works baseA85_encode:
Stages
Encoding your message in formate BaseA85
Print: encoded your message in formate BaseA85
  • How it works baseA85_decode:
Stages
Decoding message (in formate baseA85) in text
Print: decoded message
  • And how it works is_valid_baseA85:
Stages
Checks if the text is valid in formate baseA85
Print: return True or False
  • And in code:
fromfast_cryptography.algorithms.encoding.baseA85importbaseA85_encode, baseA85_decode, is_valid_baseA85text=b'Python'# Base58encoded=baseA85_encode(text)
print(encoded)
decoded=baseA85_decode(encoded)
print(decoded)
# Is validprint(is_valid_baseA85(encoded)) # True or False# Orreturnis_valid_baseA85(encodedd)

Scripts

Here 2 modules: password, what_encoding

Password

  • How import:
fromfast_cryptography.algorithms.scripts.passwordimportauth, verify
  • Or:
fromfast_cryptography.algorithms.scriptsimportpassword
  • How it works auth:
Stages
Takes password
Generating salt (32 bytes default)
Transmits password and salt in PBKDF2HMAC
Does 100.000 iteration SHA-256
Receives hash
Encoding hash in Base64
Encoding salt in HEX
Return in tuple: hash (Base64) and salt (HEX)
  • In code:
fromfast_cryptography.algorithms.scripts.passwordimportauthpwd='password'# For example, it's password don't safe!returnauth(pwd)
  • And how it works verify:
Stages
Takes entered password
Takes salt (HEX in bytes)
Takes hash (Base64 in bytes)
Recalculates hash through PBKDF2 use the same salt
Check with safe hash
Print: return True or False
  • In code:
fromfast_cryptography.algorithms.scripts.passwordimportauth, verify# Authpwd='password'hash_val, salt=auth(pwd)
# Verifyyour_pwd=input("Enter password: ").strip()
ifverify(your_pwd, hash_val, salt):
return"Correctly password", Trueelse:
return"Uncorrectly password", False

What_Encoding

  • How import:
fromfast_cryptography.algorithms.scripts.what_encodingimportwhat_encoding
  • Or:
fromfast_cryptography.algorithms.scriptsimportwhat_encoding
  • How it works:
Stages
Checks what the encoding is
Print: return encoding (For example: "Base64")
  • And in code:
fromfast_cryptography.scripts.what_encodingimportwhat_encodingprint(what_encoding("SGVsbG8=")) # Base64print(what_encoding("9Ajdvzr")) # Base58print(what_encoding("48656c6c6f")) # Base16 (HEX)print(what_encoding("Hello")) # Unknown