cryptocode


Namecryptocode JSON
Version 0.1 PyPI version JSON
download
home_pagehttps://github.com/gdavid7/cryptocode
SummaryPython library used to encrypt and decrypt strings in the simplest possible way.
upload_time2020-11-05 18:51:25
maintainer
docs_urlNone
authorgdavid7
requires_python
licenseMIT
keywords cryptocode key crypto encodestring
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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()
~~~



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/gdavid7/cryptocode",
    "name": "cryptocode",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "cryptocode,key,crypto,encodestring",
    "author": "gdavid7",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/ea/b8/f4a618a4e5e7eacaaefa5ae3531cc2c12a2c880c9a7ef7f81eed6162616f/cryptocode-0.1.tar.gz",
    "platform": "",
    "description": "# cryptocode\n\nPython library used to encrypt and decrypt strings in the simplest possible way, while also being incredibly secure.\n## Requirements\n\n\n- **Python** 3 or later.\n\n## Installation\n\nInstall some Python utilities along with some libraries and other stuff:\n\n~~~\npip install cryptocode\n~~~\n\n## Basic usage\nEncrypting a message:\n\n~~~\n>>> import cryptocode\n>>> myEncryptedMessage = cryptocode.encrypt(\"I like trains\", \"password123\")\n>>> print(myEncryptedMessage)\nM+Wykmlub0z7FhEdmA==*PvAbXRNx0SiSDHHxLsKZ5w==*ihQM/fdkgrX3G+yOItyAUQ==*QFNDmuUP1ysgo01/P2MNpg==\n~~~\n\nThe first parameter is the string you want to encrypt. The second parameter is the password, which will be used for decrypting the string.\n\nDecrypting a message\"\n~~~\n>>> import cryptocode\n>>> myDecryptedMessage = cryptocode.decrypt(\"M+Wykmlub0z7FhEdmA==*PvAbXRNx0SiSDHHxLsKZ5w==*ihQM/fdkgrX3G+yOItyAUQ==*QFNDmuUP1ysgo01/P2MNpg==\", \"password123\")\n>>> print(myDecryptedMessage)\nI like trains\n~~~\nThe first parameter is the encrypted string and the second parameter is the password. If the password is incorrect, decrypt function will return `False`.\n\n## Example\nHere, we will be creating a simple \"trial product key\". This is useful if you have software that you would like people to use temporarily.\nIn this example, we will be letting the user use the product for 2 hours. The password we will be using is ``cryptocode is amazing``.\n\nCode on the server side:\n~~~\nimport cryptocode\nimport time\nhours = 2\nmessageToEncrypt = str(time.time() + hours * 60 * 60)\n## Hours * 60 * 60 is necessary because we need to turn the hours into seconds, since the timestamp is in seconds.\ncryptocode.encrypt(messageToEncrypt, \"cryptocode is amazing\")\n~~~\n\nCode on the client side:\n~~~\nimport cryptocode\nimport time\nimport sys\n#Function to verify that the key is valid:\ndef check_valid(key):\n    message = cryptocode.decrypt(key, 'cryptocode is amazing')\n    if message == False:\n        #The key is incorrect!\n        return False\n    if float(message) >= time.time():\n        return True\n    else:\n        #The key has expired!\n        return False\nuserKeyInput = input(\"Please enter your product key.\")\nkeyChecked = check_valid(userKeyInput)\nif keyChecked == True:\n    print(\"You are good to go!\")\nif keyChecked == False:\n    print(\"You have either entered an invalid key or your time has expired. Sorry!\")\n    sys.exit()\n~~~\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python library used to encrypt and decrypt strings in the simplest possible way.",
    "version": "0.1",
    "project_urls": {
        "Homepage": "https://github.com/gdavid7/cryptocode"
    },
    "split_keywords": [
        "cryptocode",
        "key",
        "crypto",
        "encodestring"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6766f9a722cfdb9289ac1e88e537308c0f9b2f31817dee02b1addcc91584731c",
                "md5": "6cb6da5ee6cac5ba36e3d307abe77386",
                "sha256": "510e8abf8d656e47b03227a5c3845374e23ff64d9947f2bb89d7230ea3bf773a"
            },
            "downloads": -1,
            "filename": "cryptocode-0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6cb6da5ee6cac5ba36e3d307abe77386",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4106,
            "upload_time": "2020-11-05T18:51:22",
            "upload_time_iso_8601": "2020-11-05T18:51:22.686115Z",
            "url": "https://files.pythonhosted.org/packages/67/66/f9a722cfdb9289ac1e88e537308c0f9b2f31817dee02b1addcc91584731c/cryptocode-0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eab8f4a618a4e5e7eacaaefa5ae3531cc2c12a2c880c9a7ef7f81eed6162616f",
                "md5": "a5297825a5e052fde3229d4b526de22b",
                "sha256": "1cf6718e542981ceafc1000b00d60458f8620a1e5adfceb3fc297205b38774cc"
            },
            "downloads": -1,
            "filename": "cryptocode-0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "a5297825a5e052fde3229d4b526de22b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3259,
            "upload_time": "2020-11-05T18:51:25",
            "upload_time_iso_8601": "2020-11-05T18:51:25.124915Z",
            "url": "https://files.pythonhosted.org/packages/ea/b8/f4a618a4e5e7eacaaefa5ae3531cc2c12a2c880c9a7ef7f81eed6162616f/cryptocode-0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-11-05 18:51:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "gdavid7",
    "github_project": "cryptocode",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "cryptocode"
}
        
Elapsed time: 0.08997s