Skip to main content

Build Status Coverage Status PyPI version

There are a lot of different scrypt modules for Python, but none of them have everything that I’d like, so here’s One More1.

Features

  • Uses hashlib.scrypt on Python 3.6+ and OpenSSL 1.1+.

  • Uses system libscrypt2 as the next choice.

  • If neither is available, tries the scrypt Python module3 or libsodium4.

  • Offers a pure Python scrypt implementation for when there is no C scrypt.

  • Not unusably slow, even in pure Python… at least with pypy5.

With PyPy as the interpreter the Python implementation is around one fifth the speed of C scrypt. With CPython it is about 250x slower.

Requirements

  • Python 3.4+. Equivalent versions of PyPy should also work.

  • For Python 2.7.8+ support install the latest version 1.x instead.

  • If you want speed, you should use one of:

    • Python 3.6+ with OpenSSL 1.1+

    • libscrypt 1.8+ (older may work)

    • py-scrypt 0.6+ (pip install scrypt)

    • libsodium 1.0+

Usage

You can install the most recent release from PyPi using:

pip install pylibscrypt

You most likely want to create MCF hashes and store them somewhere, then check user-entered passwords against those hashes. For that you only need to use two functions from the API:

from pylibscrypt import scrypt_mcf, scrypt_mcf_check
# Generate an MCF hash with random salt
mcf = scrypt_mcf('Hello World')
# Test it
print(scrypt_mcf_check(mcf, 'Hello World'))   # prints True
print(scrypt_mcf_check(mcf, 'HelloPyWorld'))  # prints False

For full API, you can try help(pylibscrypt) from python after importing.

It is highly recommended that you use a random salt, i.e. don’t pass one.

Versioning

The package has a version number that can be read from python like so:

print(pylibscrypt.__version__)

The version number is of the form X.Y.Z, following Semantic Versioning6. Unreleased versions include a -git version specifier, e.g. 2.0.0-git < 2.0.0. Releases are tagged vX.Y.Z and release branches bX.Y.x when they differ from master.

Development

Development happens on GitHub7. If you find a bug, please open an issue there.

Running pylibscrypt.tests will test all implementations with some quick tests. Running any implementation directly (e.g. pylibscrypt.pylibsodium) will also compare to scrypt test vectors from the paper but this is slow for the pure Python version (pypyscrypt) unless running with pypy.

You can test more comprehensively using the docker test environment. Either build and run using make docker-run or pull the jvarho/pylibscrypt image and run using docker run -v ${PWD}:/app jvarho/pylibscrypt.

Pull requests should be automatically tested and will not be merged if broken.

Metadata

Release files for pylibscrypt 2.0.0

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

Source distribution (sdist)

Source distribution for pylibscrypt 2.0.0
File Size Uploaded
pylibscrypt-2.0.0.tar.gz 17.8 kB Details

Release files / pylibscrypt-2.0.0.tar.gz

Download URL pylibscrypt-2.0.0.tar.gz
Size 17.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5afffc2cf056de86a000c13627ddca87fac14380939694aa6fbf4875926c0146
BLAKE2b-256 checksum
How to use checksums
9900592c989eb07e3b28fa4d58b7a9a9808b981a4996aae2392f9ec218c5b3b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.8

Release history Release notifications | RSS feed

This release

2.0.0 This release

1 release file

1.8.0

1 release file

1.7.1

1 release file

1.7.0

1 release file

1.6.1

1 release file

1.6.0

1 release file

1.5.3

1 release file

1.5.2

1 release file

1.5.1

1 release file

1.5.0

1 release file

1.4.1

1 release file

1.4.0

1 release file

1.3.0

1 release file

1.2.1

1 release file

1.2.0

1 release file

1.1.3

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

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