Skip to main content

cryptocode

Python library used to encrypt and decrypt strings in the simplest possible way, while also being incredibly secure.

Requirements

  • Python 3 or later.

Installation

Install some Python utilities along with some libraries and other stuff:

pip install cryptocode

Basic usage

Encrypting a message:

>>> import cryptocode
>>> myEncryptedMessage = cryptocode.encrypt("I like trains", "password123")
>>> print(myEncryptedMessage)
M+Wykmlub0z7FhEdmA==*PvAbXRNx0SiSDHHxLsKZ5w==*ihQM/fdkgrX3G+yOItyAUQ==*QFNDmuUP1ysgo01/P2MNpg==

The first parameter is the string you want to encrypt. The second parameter is the password, which will be used for decrypting the string.

Decrypting a message"

>>> import cryptocode
>>> myDecryptedMessage = cryptocode.decrypt("M+Wykmlub0z7FhEdmA==*PvAbXRNx0SiSDHHxLsKZ5w==*ihQM/fdkgrX3G+yOItyAUQ==*QFNDmuUP1ysgo01/P2MNpg==", "password123")
>>> print(myDecryptedMessage)
I like trains

The first parameter is the encrypted string and the second parameter is the password. If the password is incorrect, decrypt function will return False.

Example

Here, we will be creating a simple "trial product key". This is useful if you have software that you would like people to use temporarily. In this example, we will be letting the user use the product for 2 hours. The password we will be using is cryptocode is amazing.

Code on the server side:

import cryptocode
import time
hours = 2
messageToEncrypt = str(time.time() + hours * 60 * 60)
## Hours * 60 * 60 is necessary because we need to turn the hours into seconds, since the timestamp is in seconds.
cryptocode.encrypt(messageToEncrypt, "cryptocode is amazing")

Code on the client side:

import cryptocode
import time
import sys
#Function to verify that the key is valid:
def check_valid(key):
    message = cryptocode.decrypt(key, 'cryptocode is amazing')
    if message == False:
        #The key is incorrect!
        return False
    if float(message) >= time.time():
        return True
    else:
        #The key has expired!
        return False
userKeyInput = input("Please enter your product key.")
keyChecked = check_valid(userKeyInput)
if keyChecked == True:
    print("You are good to go!")
if keyChecked == False:
    print("You have either entered an invalid key or your time has expired. Sorry!")
    sys.exit()

Metadata

Release files for cryptocode 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cryptocode 0.1
File Size Uploaded
cryptocode-0.1.tar.gz 3.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cryptocode 0.1
File Interpreter ABI Platform
cryptocode-0.1-py3-none-any.whl Python 3 none any Details

Total release size: 7.4 kB

Release files / cryptocode-0.1.tar.gz

Download URL cryptocode-0.1.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1cf6718e542981ceafc1000b00d60458f8620a1e5adfceb3fc297205b38774cc
BLAKE2b-256 checksum
How to use checksums
eab8f4a618a4e5e7eacaaefa5ae3531cc2c12a2c880c9a7ef7f81eed6162616f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.23.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.7

Release files / cryptocode-0.1-py3-none-any.whl

Download URL cryptocode-0.1-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
510e8abf8d656e47b03227a5c3845374e23ff64d9947f2bb89d7230ea3bf773a
BLAKE2b-256 checksum
How to use checksums
6766f9a722cfdb9289ac1e88e537308c0f9b2f31817dee02b1addcc91584731c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.23.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.7

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page