Skip to main content

Crypto Bakery

Project description

CryptoBaker

Installation:

  • via pypi: pip install cryptobaker
  • via githup: pip install git+https://github.com/AgeOfMarcus/cryptobaker
  • from source:
$ git clone https://github.com/AgeOfMarcus/cryptobaker
$ cd cryptobaker
$ python setup.py install

Dish and Recipe objects

The Dish object is what you start with. Recipes can only be applied to dishes. You create a dish like so: x = Dish("Hello, world!")

A Recipe object will be seen less often, but it can be useful in some cases. Let's say you've made a dish like so, x = Dish("hello world").apply(toDecimal).apply(toMorse), and want to create another dish with the same recipe. The recipe of any dish can be accessed through the .recipe attribute, eg: x.recipe which will return <Recipe: toDecimal -> toMorse>. To make another dish with the recipe from x, you would do: y = Bake("goodbye world", x.recipe).

recipes

Some recipes have no arguments, they are applied like so: x.apply(toBase64). Some recipes require argument(s) and/or keyword argument(s), they can be applied in two ways, either like x.apply(XOR("0110")), or like this x.apply(XOR, "0110"). Both do the same thing.

Similarly, keyword arguments can be applied in two ways. x.apply(toMorse(dot="*")) or x.apply(toMorse, dot="*").

Not all recipes begin with to or from. Some examples of recipies that don't are:

  • XOR - this is because to reverse the process, you just apply XOR again with the same key
  • split - this is a string manipulation method, it can be 'reversed' with join
  • join - this is a list manipulation method, it can be 'reversed' with split

Not all recipes that begin with to have a counterpart. For example, all of the hashing recipes (such as toSHA256). This is because hashes are irreversable by nature.

Examples

Good hashing recipe

from cryptobaker import *

hashr = lambda x: ("salt" + Dish(x).apply(toSHA256)).apply(toMD5)
print(hashr("password")) # '9f3b7f774efa78c8dd6df5e0ff1cb67d'

Encoder and Decoder

from cryptobaker import *

encr = Recipe(toDecimal, toBinary, join(" "), toBase64)
decr = Recipe(fromBase64, split(" "), fromBinary, fromDecimal, join)

enc = encr.cook("Hello, world!")
dec = decr.cook(enc)

dec == "Hello, world!"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

CryptoBaker-0.8.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file CryptoBaker-0.8.1-py3-none-any.whl.

File metadata

  • Download URL: CryptoBaker-0.8.1-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5

File hashes

Hashes for CryptoBaker-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4527d09da34981ac395aebdcec76f1c8c6b1d6813bd751de0f46fc951491204e
MD5 cb5868c5afc79e2573437d706e0362fe
BLAKE2b-256 32fbbd4ae02e03673d0c5b72ff9092cd1557d7fe12dbe6a72a51d565856bafa7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page