{"id":15019700,"url":"https://github.com/furritos/flask-simple-crypt","last_synced_at":"2025-10-24T14:32:23.867Z","repository":{"id":45911425,"uuid":"73890694","full_name":"furritos/flask-simple-crypt","owner":"furritos","description":"Flask extension based on simple-crypt that allows simple, secure encryption and decryption for Python.","archived":false,"fork":false,"pushed_at":"2022-12-07T08:12:30.000Z","size":63,"stargazers_count":3,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T02:36:22.949Z","etag":null,"topics":["cryptography","decryption","encryption","flask","python","security","symmetric","symmetric-cryptography"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/Flask-Simple-Crypt/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/furritos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-16T06:25:15.000Z","updated_at":"2022-12-16T04:01:53.000Z","dependencies_parsed_at":"2023-01-24T15:30:40.413Z","dependency_job_id":null,"html_url":"https://github.com/furritos/flask-simple-crypt","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furritos%2Fflask-simple-crypt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furritos%2Fflask-simple-crypt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furritos%2Fflask-simple-crypt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/furritos%2Fflask-simple-crypt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/furritos","download_url":"https://codeload.github.com/furritos/flask-simple-crypt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237990674,"owners_count":19398475,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cryptography","decryption","encryption","flask","python","security","symmetric","symmetric-cryptography"],"created_at":"2024-09-24T19:53:54.504Z","updated_at":"2025-10-24T14:32:20.038Z","avatar_url":"https://github.com/furritos.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![furritos](https://circleci.com/gh/furritos/flask-simple-crypt.svg?style=svg)](https://circleci.com/gh/furritos/flask-simple-crypt)\n\n# Flask-Simple-Crypt\n\nFlask extension based on `simple-crypt` that allows simple, secure encryption and decryption for Python.  The original module is available in [pypi](http://pypi.python.org/pypi/simple-crypt) and [github](https://github.com/andrewcooke/simple-crypt).\n\n## Overview\n\nThis Flask extension provides two functions, which encrypt and decrypt data, delegating all the hard work to the [pycrypto](https://www.dlitz.net/software/pycrypto) \n\n## Dependencies\n\n - Python 3.7 or greater\n - Flask 2.1.0 or greater\n - PyCryptoDome 3.15.0 or greater\n\n## Install from PyPi\n\n```\npip install flask-simple-crypt\n```\n\n## Install from source\n\n```\ngit clone https://github.com/furritos/flask-simple-crypt\npython setup.py install\n```\n\n## Usage \n\n### Simple Flask Application\n\nFor this extension to work properly, a `SECRET_KEY` must be defined.  It is **strongly** suggested that one use strong key, **especially** when working with sensitive data.\n\n```\nfrom flask import Flask\nfrom flask_simple_crypt import SimpleCrypt\n\napp = Flask(__name__)\napp.config['SECRET_KEY'] = \"this is my key!\"\n\ncipher = SimpleCrypt()\ncipher.init_app(app)\n\nenc_data = cipher.encrypt(\"shhhhhhh!\")\nprint(enc_data)  # returns base64 encoded and encrypted data\n\ndec_data = cipher.decrypt(enc_data)\nprint(dec_data)  # returns original data\n```\n\n## Performance\n\nBoth encryption and decryption are can be relatively slow.  However, this is a tunable parameter. In the original version of **simple-crypt**, there is a fixed value of 10,000 iterations.\n\nWith `flask-simple-crypt`, this value is now tunable from the default of 25,000.  Obviously, this needs to be adjust for acceptable performance.  To override this, simply add `FSC_EXPANSION_COUNT` into the Flask configuration manifest:\n\n```\nfrom flask import Flask\nfrom flask_simple_crypt import SimpleCrypt\n\nimport time\n\napp = Flask(__name__)\napp.config['SECRET_KEY'] = \"this is my key!\"\napp.config['FSC_EXPANSION_COUNT'] = 2048\n\ncipher = SimpleCrypt()\ncipher.init_app(app)\n\nstart = time.time()\nenc_data = cipher.encrypt(\"shhhhhhh!\")\ndec_data = cipher.decrypt(enc_data)\nend = time.time()\nprint(end - start)\n```\n\nOn an i5, 2.5 Ghz machine, this finished in about .2 seconds.\nWith `app.config['FSC_EXPANSION_COUNT'] = 20000`, it finished in about 2.1 seconds.\nFinally, with `app.config['FSC_EXPANSION_COUNT'] = 200000`, it finished in about 21 seconds.\n\nGenerally, the thinking is that this lapse in processing would deter any would be attackers from programmatically brute forcing their way into the passwords.  Again, tune to your liking, balancing performance with security, but be cognizant that this library is designed to make the key (the password) hard to guess (it uses a [PBKDF](https://en.wikipedia.org/wiki/Key_derivation_function), which can take a couple of seconds to run).\n\nTo quote the [original](https://github.com/andrewcooke/simple-crypt#speed):\n\n\u003e In simple terms, if an attacker tries to decrypt the data by guessing passwords, then they *also* have to wait for a couple of seconds for each guess.  This stops an attacker from trying \"thousands\" of different passwords every second.\n\n\u003e So the pause on encryption and decryption is actually a sign that the library is protecting you.  If this is unacceptable for your program then you may need to look for a different solution.  I'm sorry, but this is the trade-off I chose when writing simple-crypt.\n\n## Algorithms\n\nNotable exceptions from the original implementation are as follows:\n\n* The password is expanded to two 256 bit keys using PBKDF2 with a 256 bit random salt, SHA256, and 25,000 iterations.\n\n* An encrypted messages starts with a 5 byte header (**fsc** in ASCII followed by two bytes containing version data).\n\n* On top of the above mentioned encryption, the result is then base64 encoded for ease of use with databases.\n\n* Built against Release 4.1 of `simple-crypt`.\n\n## Warnings\n\nHeed the [same](https://github.com/andrewcooke/simple-crypt#warnings) as the original.\n\n## Credits\n\nMuch of the work has been made possible thanks to [Andrew Cooke's](https://github.com/andrewcooke) original work.  The purpose (and focus) of this project was to `flaskify` it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffurritos%2Fflask-simple-crypt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffurritos%2Fflask-simple-crypt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffurritos%2Fflask-simple-crypt/lists"}