Skip to main content

Python scrypt bindings

This github is a clone of https://bitbucket.org/mhallin/py-scrypt. Please add issues and Pull-requests there.

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:

$ git clone https://github.com/holgern/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-python was created by Magnus Hallin and is licensed as 2-clause BSD.

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.

Badges

https://travis-ci.org/holgern/py-scrypt.svg?branch=master https://ci.appveyor.com/api/projects/status/h644bjbdawke9vf2?svg=true

Metadata

Release files for scrypt 0.8.2

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

Built distributions (wheels)

Table of built distributions (wheels) for scrypt 0.8.2
File Actions
scrypt-0.8.2.win-amd64-py3.6.exe Details for scrypt-0.8.2.win-amd64-py3.6.exe
scrypt-0.8.2.win-amd64-py3.5.exe Details for scrypt-0.8.2.win-amd64-py3.5.exe
scrypt-0.8.2.win-amd64-py3.4.exe Details for scrypt-0.8.2.win-amd64-py3.4.exe
scrypt-0.8.2.win-amd64-py2.7.exe Details for scrypt-0.8.2.win-amd64-py2.7.exe
scrypt-0.8.2.win32-py3.6.exe Details for scrypt-0.8.2.win32-py3.6.exe
scrypt-0.8.2.win32-py3.5_2.exe Details for scrypt-0.8.2.win32-py3.5_2.exe
scrypt-0.8.2.win32-py3.4.exe Details for scrypt-0.8.2.win32-py3.4.exe
scrypt-0.8.2.win32-py2.7.exe Details for scrypt-0.8.2.win32-py2.7.exe
scrypt-0.8.2-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details for scrypt-0.8.2-cp36-cp36m-win_amd64.whl
scrypt-0.8.2-cp36-cp36m-win32.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-32 Details for scrypt-0.8.2-cp36-cp36m-win32.whl
scrypt-0.8.2-cp36-cp36m-macosx_10_6_intel.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.6+ Intel (x86-64, i386) Details for scrypt-0.8.2-cp36-cp36m-macosx_10_6_intel.whl
scrypt-0.8.2-cp35-cp35m-win_amd64.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-64 Details for scrypt-0.8.2-cp35-cp35m-win_amd64.whl
scrypt-0.8.2-cp35-cp35m-win32.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-32 Details for scrypt-0.8.2-cp35-cp35m-win32.whl
scrypt-0.8.2-cp35-cp35m-macosx_10_6_intel.whl CPython 3.5 CPython 3.5 pymalloc macOS 10.6+ Intel (x86-64, i386) Details for scrypt-0.8.2-cp35-cp35m-macosx_10_6_intel.whl
scrypt-0.8.2-cp34-cp34m-win_amd64.whl CPython 3.4 CPython 3.4 pymalloc Windows x86-64 Details for scrypt-0.8.2-cp34-cp34m-win_amd64.whl
scrypt-0.8.2-cp34-cp34m-win32.whl CPython 3.4 CPython 3.4 pymalloc Windows x86-32 Details for scrypt-0.8.2-cp34-cp34m-win32.whl
scrypt-0.8.2-cp27-cp27m-win_amd64.whl CPython 2.7 CPython 2.7 pymalloc Windows x86-64 Details for scrypt-0.8.2-cp27-cp27m-win_amd64.whl
scrypt-0.8.2-cp27-cp27m-win32.whl CPython 2.7 CPython 2.7 pymalloc Windows x86-32 Details for scrypt-0.8.2-cp27-cp27m-win32.whl

Total release size: 3.4 MB

Release files / scrypt-0.8.2.win-amd64-py3.6.exe

Download URL scrypt-0.8.2.win-amd64-py3.6.exe
Size 619.4 kB
Tags Source
SHA-256 checksum
How to use checksums
80cc2a8fce8d7c0c1fa03def3f678fd6f2c51b55f04c8c14eeb7e6b77197ed9c
BLAKE2b-256 checksum
How to use checksums
112d0d6b68d3a7f51e0774331a42cb36537e9ed5b09bc8477866eae74440e241
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / scrypt-0.8.2.win-amd64-py3.5.exe

Download URL scrypt-0.8.2.win-amd64-py3.5.exe
Size 619.4 kB
Tags Source
SHA-256 checksum
How to use checksums
cbb46cd2a6d01e700e2d192965b63e77bbda5aa55a6d4218db60221ebd642d34
BLAKE2b-256 checksum
How to use checksums
da423bbc123f6928baf496fd7e73dbc30af299942bc1b06796cb30b954144cc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / scrypt-0.8.2.win-amd64-py3.4.exe

Download URL scrypt-0.8.2.win-amd64-py3.4.exe
Size 251.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ead6330c39ec39c80b59739bad7d0211de119f0193d614f820c6ce7fc5b47372
BLAKE2b-256 checksum
How to use checksums
1ee68400e01d2d33403dcbaded74308f43279088c5e1754384fe5c7ad4efeaca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / scrypt-0.8.2.win-amd64-py2.7.exe

Download URL scrypt-0.8.2.win-amd64-py2.7.exe
Size 252.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b615ed7e81623fd8bd4fb8fab158c54e6ccbf388b295523d3b677ff3bf72582d
BLAKE2b-256 checksum
How to use checksums
db2781ea7d333de5addccf7e264a71ab2ed3cd3d0043eb53f323b1733fbddfa9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / scrypt-0.8.2.win32-py3.6.exe

Download URL scrypt-0.8.2.win32-py3.6.exe
Size 485.7 kB
Tags Source
SHA-256 checksum
How to use checksums
40c9d861ae5a065800b6afcc8d8fac171b1b326e5ce1dd5b18b7f01da9d5a2e9
BLAKE2b-256 checksum
How to use checksums
be1b06ebc20acc6739f9a08084e0795a4c2de1d6cf9cbbbec7b95e6aa5eca497
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / scrypt-0.8.2.win32-py3.5_2.exe

Download URL scrypt-0.8.2.win32-py3.5_2.exe
Size 485.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ef22551731a8007f11433becd505edb83a87181f5f303ca09d816065c6174b86
BLAKE2b-256 checksum
How to use checksums
eb94cade1771044560bf185cdfcce1721645b236d70d815300600e8851e8b8d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / scrypt-0.8.2.win32-py3.4.exe

Download URL scrypt-0.8.2.win32-py3.4.exe
Size 216.8 kB
Tags Source
SHA-256 checksum
How to use checksums
22631b4d5da7b3881bca34e7a0a519dc0a71271f47e2c2c73c7cb4573efdeed5
BLAKE2b-256 checksum
How to use checksums
52aecb9ec75bc6ba5bf6dfa38538ab6ac77229f050ef7d7ce0d01e4165f41298
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / scrypt-0.8.2.win32-py2.7.exe

Download URL scrypt-0.8.2.win32-py2.7.exe
Size 221.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f537bfd4547cbfad872c9324ea35b19c81e38ffceb1778bbaa3820517803fe6b
BLAKE2b-256 checksum
How to use checksums
4d9660864151eaa372498b1a560541e60f301ea40a3fdb80e1d8e3280418239a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / scrypt-0.8.2-cp36-cp36m-win_amd64.whl

Download URL scrypt-0.8.2-cp36-cp36m-win_amd64.whl
Size 28.4 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
2da82b740b22d49010c3951ff0aa2a05f6fbd5073b1a0c07e5b882290d88ac9d
BLAKE2b-256 checksum
How to use checksums
593b82493e2ec001f3b770f2da17b71a73131625630d7ac38ddcd2968fa659b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / scrypt-0.8.2-cp36-cp36m-win32.whl

Download URL scrypt-0.8.2-cp36-cp36m-win32.whl
Size 24.3 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
7670a9497d777e79caf0b066aa433756230f1a8162230a6dab517f71dea00b65
BLAKE2b-256 checksum
How to use checksums
f03614bb5c624d18f049bc016e1b406bcd19db78c9af0dc92ab9bea88c4131bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / scrypt-0.8.2-cp36-cp36m-macosx_10_6_intel.whl

Download URL scrypt-0.8.2-cp36-cp36m-macosx_10_6_intel.whl
Size 45.0 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
aa4a25250aee1c424fabec90b4ada06f6687d071f66061e5f9a3926db50e02e5
BLAKE2b-256 checksum
How to use checksums
344d3b97e5f56560eb48d06144047e5980ee72dac718c45e323457f4c7562452
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / scrypt-0.8.2-cp35-cp35m-win_amd64.whl

Download URL scrypt-0.8.2-cp35-cp35m-win_amd64.whl
Size 28.4 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
90512045b35766f36a32f14ea811455597338bcaf766d63355781530e99c59e7
BLAKE2b-256 checksum
How to use checksums
19fc2f0677012caa729bbf71ccae795512095b49010a37ae18fd8a23027c6039
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / scrypt-0.8.2-cp35-cp35m-win32.whl

Download URL scrypt-0.8.2-cp35-cp35m-win32.whl
Size 24.3 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
ed8b1ac20c9713a3cc3d0a44caf140bd1c80ff6bbf4ca61f3b7de793d8bb184f
BLAKE2b-256 checksum
How to use checksums
cb592d998158ea7b3ee13ad5ea7b033b4c56d314c13f23f6e21fdbcebb6f936c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / scrypt-0.8.2-cp35-cp35m-macosx_10_6_intel.whl

Download URL scrypt-0.8.2-cp35-cp35m-macosx_10_6_intel.whl
Size 44.9 kB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
b06728bcdb429eb9686b01b3a79cacca153e1120194e0616e319e72f4691be5d
BLAKE2b-256 checksum
How to use checksums
df1dccb285da23b3e28fa44f968e96fceccc4c89639da16a7a9f3c34342b8127
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / scrypt-0.8.2-cp34-cp34m-win_amd64.whl

Download URL scrypt-0.8.2-cp34-cp34m-win_amd64.whl
Size 25.8 kB
Tags CPython 3.4 CPython 3.4 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
874fb61f9020e86b212d271808af3c061bacf6eace5f71f2de2c91e921e6ceee
BLAKE2b-256 checksum
How to use checksums
8c232bc26904d5f035a91741b2a21de5d9289ac5f95eb28edb40197c73f2b87f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / scrypt-0.8.2-cp34-cp34m-win32.whl

Download URL scrypt-0.8.2-cp34-cp34m-win32.whl
Size 22.6 kB
Tags CPython 3.4 CPython 3.4 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
e880524c23f52783f289d47e71231631d1889dc749ef5e54fb422c34d0684af6
BLAKE2b-256 checksum
How to use checksums
6b9e22ca8c7b5424524d33a8b069d1dfc2c20d3a169eb1f86d198ca38d3d8e0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / scrypt-0.8.2-cp27-cp27m-win_amd64.whl

Download URL scrypt-0.8.2-cp27-cp27m-win_amd64.whl
Size 25.4 kB
Tags CPython 2.7 CPython 2.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
737eb4421013b27f9ee13fdc42544b79977eba74e254eec037c9a207e105fd27
BLAKE2b-256 checksum
How to use checksums
998c441473bb0f8e6b24ee853b2518fb1db8cc84d3017ff7801d1c3dfae96779
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / scrypt-0.8.2-cp27-cp27m-win32.whl

Download URL scrypt-0.8.2-cp27-cp27m-win32.whl
Size 22.6 kB
Tags CPython 2.7 CPython 2.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
b22e49242fed57a23f02dc294a562591b63aa317c5b41ba4b3673e3f73dd26a1
BLAKE2b-256 checksum
How to use checksums
1e7f3eeb63e009c8b065089da19b63268043adafd01436e53caf95558b7c0539
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for scrypt 0.8.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.8.2 This release

18 release files No provenance

0.4.0

0.3.0

0.1.0

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