4 files were added to this release more than 14 days after its initial publication. Inspect the release files before installing.
This is a set of Python bindings for the scrypt key derivation function.
Scrypt is useful when encrypting password as it is possible to specify a minimum amount of time to use when encrypting and decrypting. If, for example, a password takes 0.05 seconds to verify, a user won’t notice the slight delay when signing in, but doing a brute force search of several billion passwords will take a considerable amount of time. This is in contrast to more traditional hash functions such as MD5 or the SHA family which can be implemented extremely fast on cheap hardware.
Installation
You can install py-scrypt from this repository if you want the latest but possibly non-compiling version:
$ hg clone http://bitbucket.org/mhallin/py-scrypt $ cd py-scrypt $ python setup.py build Become superuser (or use virtualenv): # python setup.py install Run tests after install: $ python setup.py test
Or you can install the latest release from PyPi:
$ pip install scrypt
If you want py-scrypt for your Python 3 environment, just run the above commands with your Python 3 interpreter. Py-scrypt supports both Python 2 and 3.
>From version 0.6.0 (not available on PyPi yet), py-scrypt supports PyPy as well.
Usage
Fore encryption/decryption, the library exports two functions encrypt and decrypt:
>>> import scrypt
>>> data = scrypt.encrypt('a secret message', 'password', maxtime=0.1) # This will take at least 0.1 seconds
>>> data[:20]
'scrypt\x00\r\x00\x00\x00\x08\x00\x00\x00\x01RX9H'
>>> scrypt.decrypt(data, 'password', maxtime=0.1) # This will also take at least 0.1 seconds
'a secret message'
>>> scrypt.decrypt(data, 'password', maxtime=0.05) # scrypt won't be able to decrypt this data fast enough
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
scrypt.error: decrypting file would take too long
>>> scrypt.decrypt(data, 'wrong password', maxtime=0.1) # scrypt will throw an exception if the password is incorrect
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
scrypt.error: password is incorrect
>From these, one can make a simple password verifier using the following functions:
def hash_password(password, maxtime=0.5, datalength=64):
return scrypt.encrypt(os.urandom(datalength), password, maxtime=maxtime)
def verify_password(hashed_password, guessed_password, maxtime=0.5):
try:
scrypt.decrypt(hashed_password, guessed_password, maxtime)
return True
except scrypt.error:
return False
But, if you want output that is deterministic and constant in size, you can use the hash function:
>>> import scrypt
>>> h1 = scrypt.hash('password', 'random salt')
>>> len(h1) # The hash will be 64 bytes by default, but is overridable.
64
>>> h1[:10]
'\xfe\x87\xf3hS\tUo\xcd\xc8'
>>> h2 = scrypt.hash('password', 'random salt')
>>> h1 == h2 # The hash function is deterministic
True
Acknowledgements
Scrypt was created by Colin Percival and is licensed as 2-clause BSD. Since scrypt does not normally build as a shared library, I have included the source for the currently latest version of the library in this repository. When a new version arrives, I will update these sources.
Kelvin Wong on Bitbucket provided changes to make the library available on Mac OS X 10.6 and earlier, as well as changes to make the library work more like the command-line version of scrypt by default. Kelvin also contributed with the unit tests, lots of cross platform testing and work on the hash function.
Burstaholic on Bitbucket provided the necessary changes to make the library build on Windows.
The python-appveyor-demo repository for setting up automated Windows builds for a multitude of Python versions.
License
This library is licensed under the same license as scrypt; 2-clause BSD.
Release files for scrypt 0.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Files added late
4 files were uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release files before installing.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| scrypt-0.8.0.tar.gz | 39.0 kB | Details |
Built distributions (wheels)
Total release size: 3.4 MB
Release files / scrypt-0.8.0.tar.gz
| Download URL | scrypt-0.8.0.tar.gz |
|---|---|
| Size | 39.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d4a5a4f53450b8ef629bbf1ee4be6105c69936e49b3d8bc621ac2287f0c86020
|
|
BLAKE2b-256 checksum How to use checksums |
af8244b030646b9de44ba5a5c7e87b0419a4d44318ba18468f5292b9c16737ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / scrypt-0.8.0.win-amd64-py3.6.exe
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | scrypt-0.8.0.win-amd64-py3.6.exe |
|---|---|
| Size | 617.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c10758dcad897e20de93100a2c908746c4b4955d00fca2ac3d6aa83abc92f804
|
|
BLAKE2b-256 checksum How to use checksums |
4afdbc6e148165fc55e0731bc1d61c91269ff536d940554c1940fa721dbef155
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / scrypt-0.8.0.win-amd64-py3.5.exe
| Download URL | scrypt-0.8.0.win-amd64-py3.5.exe |
|---|---|
| Size | 619.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bb141584fa0ebdfb8a2a1fc7ddcf119ee18b1b9cd0fb3e4df9615760648b9d49
|
|
BLAKE2b-256 checksum How to use checksums |
9fd73e1ac996ca962f3be6c31fce30e7e68c9e832bd66da48e49b037336251bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / scrypt-0.8.0.win-amd64-py3.4.exe
| Download URL | scrypt-0.8.0.win-amd64-py3.4.exe |
|---|---|
| Size | 248.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aeab005a8ae43a6e5d0165ce433a15955b151045d2bbfc52a8c96f100f825323
|
|
BLAKE2b-256 checksum How to use checksums |
ce558382b9d87625627a522e9ec3deca416160b7a16a3e03ef8095f5d98e6bca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / scrypt-0.8.0.win-amd64-py2.7.exe
| Download URL | scrypt-0.8.0.win-amd64-py2.7.exe |
|---|---|
| Size | 250.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4333b67f190e5eaddc8800aefe33abd7e81b589bbe84a84be66872a4955dad6e
|
|
BLAKE2b-256 checksum How to use checksums |
3eb8e09f4f557ce21459a691d8bf3072affac31379941586229f857788b2034a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / scrypt-0.8.0.win32-py3.6.exe
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | scrypt-0.8.0.win32-py3.6.exe |
|---|---|
| Size | 485.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a11f408ffcf7bd9867c4a6e3f5f0782f5f5ba53da375dc0400855b200070376b
|
|
BLAKE2b-256 checksum How to use checksums |
6d13d0d8f1cd61fb4002df99e472027d116d040cb9ac82496254283c7f04cfd0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / scrypt-0.8.0.win32-py3.5.exe
| Download URL | scrypt-0.8.0.win32-py3.5.exe |
|---|---|
| Size | 487.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c8909a2089fd1199781aa7ce2cb66b8866d40a9f9e1fba082e067ed9524d87e9
|
|
BLAKE2b-256 checksum How to use checksums |
66ab33c328c4524fe5fd351bab4b7ac75bbb424dc3e3bb3720b08b258ef93dbe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / scrypt-0.8.0.win32-py3.4.exe
| Download URL | scrypt-0.8.0.win32-py3.4.exe |
|---|---|
| Size | 216.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
136f7d1caf596c5ee1fc7eab223605e956c3f61f77090fd9ea4e3e57a2040b78
|
|
BLAKE2b-256 checksum How to use checksums |
fc20a33b760556071e4ff8a247369667c0d1b085c91c8fcab2158d9821f47b4c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / scrypt-0.8.0.win32-py2.7.exe
| Download URL | scrypt-0.8.0.win32-py2.7.exe |
|---|---|
| Size | 221.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6109a4df8c88f851df18a1a451e533dcc47e17cfe0e4561f4e08a82669ddc942
|
|
BLAKE2b-256 checksum How to use checksums |
b74bb11eac2aa846231ade35f323e7ad5c98f3c5f77c3b6b2ca33e24afe9518c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / scrypt-0.8.0-cp36-cp36m-win_amd64.whl
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | scrypt-0.8.0-cp36-cp36m-win_amd64.whl |
|---|---|
| Size | 26.5 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
7e3be5fe70f74a01a83c60da0b010b2fe6c3d3a11b8a1c9532b583c9a440d529
|
|
BLAKE2b-256 checksum How to use checksums |
a9fd3f566dfd4d0586a5d9cad49dd3505ce03a0955ddcef43d8c1fd364c2551a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / scrypt-0.8.0-cp36-cp36m-win32.whl
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | scrypt-0.8.0-cp36-cp36m-win32.whl |
|---|---|
| Size | 24.1 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Windows x86-32 |
|
SHA-256 checksum How to use checksums |
59a03822df232a30246b59a3801292a350d19fa636f11ea86df2214f35dade22
|
|
BLAKE2b-256 checksum How to use checksums |
66e66299f57d422ad5d214f485775534b9aaaf5b09f883b728273be39a5c325f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / scrypt-0.8.0-cp35-cp35m-win_amd64.whl
| Download URL | scrypt-0.8.0-cp35-cp35m-win_amd64.whl |
|---|---|
| Size | 26.5 kB |
| Tags | CPython 3.5 CPython 3.5 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
3422d11652cd12550540675e9fb54a1de6d60f3cbfedfb067284ef028589e2ee
|
|
BLAKE2b-256 checksum How to use checksums |
b63c86905ae974620275039785bdf54cc44dcaae97dcc04335a134998672cef5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / scrypt-0.8.0-cp35-cp35m-win32.whl
| Download URL | scrypt-0.8.0-cp35-cp35m-win32.whl |
|---|---|
| Size | 24.2 kB |
| Tags | CPython 3.5 CPython 3.5 pymalloc Windows x86-32 |
|
SHA-256 checksum How to use checksums |
c37a1f8440d7c621d9f23f3c1f2a28848bc50fefbca581fd7a1b01583a083c07
|
|
BLAKE2b-256 checksum How to use checksums |
ec8f89ee71b476225707a5c84b78545e0af837d275fd863d7a41c1444191822f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / scrypt-0.8.0-cp35-cp35m-macosx_10_11_x86_64.whl
| Download URL | scrypt-0.8.0-cp35-cp35m-macosx_10_11_x86_64.whl |
|---|---|
| Size | 23.5 kB |
| Tags | CPython 3.5 CPython 3.5 pymalloc macOS 10.11+ x86-64 |
|
SHA-256 checksum How to use checksums |
c0f90cabb8f6eaec05de5ce9aa9a9b67dc63d644e6b803beb1c43ae9b9452b65
|
|
BLAKE2b-256 checksum How to use checksums |
06b132fd6710517e852b4bd17cc0d4233c5d857940fe280f599d90350e5530e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / scrypt-0.8.0-cp34-cp34m-win_amd64.whl
| Download URL | scrypt-0.8.0-cp34-cp34m-win_amd64.whl |
|---|---|
| Size | 23.9 kB |
| Tags | CPython 3.4 CPython 3.4 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
60e8c96a287ab892d9c7e1523d157ccfbdbe66da0c31738c8ed5732c2eea6a23
|
|
BLAKE2b-256 checksum How to use checksums |
f477bc0e0998bffd6825f3c392ddef078ade69e1ad99c8b111f7f2df91ea6c84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / scrypt-0.8.0-cp34-cp34m-win32.whl
| Download URL | scrypt-0.8.0-cp34-cp34m-win32.whl |
|---|---|
| Size | 22.7 kB |
| Tags | CPython 3.4 CPython 3.4 pymalloc Windows x86-32 |
|
SHA-256 checksum How to use checksums |
ae2fd88756fb4d98ccc5e2639af55eeb80863b3f9f6e0f539e5ce050964cdd5e
|
|
BLAKE2b-256 checksum How to use checksums |
7f8224ea13e114337a9fa73b39c74f1fe4ce686e793361b80da7946820b3999c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / scrypt-0.8.0-cp27-cp27m-win32.whl
| Download URL | scrypt-0.8.0-cp27-cp27m-win32.whl |
|---|---|
| Size | 22.7 kB |
| Tags | CPython 2.7 CPython 2.7 pymalloc Windows x86-32 |
|
SHA-256 checksum How to use checksums |
4e3cd639cc83e3f2c2241a01ebef9487c48b1ddf2d78f430d82d8f9ef60c6271
|
|
BLAKE2b-256 checksum How to use checksums |
a8dbbd9f8ed6ac8293c957646053139e569b4c9fd2a5f7b95d1d70be3ee8fc72
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / scrypt-0.8.0-cp27-cp27m-macosx_10_11_x86_64.whl
| Download URL | scrypt-0.8.0-cp27-cp27m-macosx_10_11_x86_64.whl |
|---|---|
| Size | 23.4 kB |
| Tags | CPython 2.7 CPython 2.7 pymalloc macOS 10.11+ x86-64 |
|
SHA-256 checksum How to use checksums |
dc9abe69799ca423b938a06ddc33e5873e493ffcd68dbb9ba48396979b210d39
|
|
BLAKE2b-256 checksum How to use checksums |
c2116656172288c2cc647d9606b163f43293859777bf3206c78d7f36e89fbb9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |