• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

scrypt/H16-Apr-2021-635500

scrypt-1.2.1/H16-Apr-2021-4,8502,647

scrypt-windows-stubs/H16-Apr-2021-763449

scrypt.egg-info/H03-May-2022-288201

src/H16-Apr-2021-10051

LICENSEH A D21-May-20201.4 KiB2721

MANIFEST.inH A D21-May-2020679 2622

PKG-INFOH A D16-Apr-202110.4 KiB288201

README.rstH A D15-Apr-20217.4 KiB265179

setup.cfgH A D16-Apr-202142 53

setup.pyH A D15-Apr-20215.3 KiB128115

README.rst

1=========================
2 Python scrypt_ bindings
3=========================
4
5This is a set of Python_ bindings for the scrypt_ key derivation
6function.
7
8.. image:: https://img.shields.io/pypi/v/scrypt.svg
9    :target: https://pypi.python.org/pypi/scrypt/
10    :alt: Latest Version
11
12.. image:: https://anaconda.org/conda-forge/scrypt/badges/version.svg
13    :target: https://anaconda.org/conda-forge/scrypt
14
15.. image:: https://anaconda.org/conda-forge/scrypt/badges/downloads.svg
16    :target: https://anaconda.org/conda-forge/scrypt
17
18
19.. image:: https://ci.appveyor.com/api/projects/status/h644bjbdawke9vf2?svg=true
20    :target: https://ci.appveyor.com/project/holger80/py-scrypt
21
22.. image:: https://www.travis-ci.com/holgern/py-scrypt.svg?branch=master
23    :target: https://www.travis-ci.com/holgern/py-scrypt
24
25Scrypt is useful when encrypting password as it is possible to specify
26a *minimum* amount of time to use when encrypting and decrypting. If,
27for example, a password takes 0.05 seconds to verify, a user won't
28notice the slight delay when signing in, but doing a brute force
29search of several billion passwords will take a considerable amount of
30time. This is in contrast to more traditional hash functions such as
31MD5 or the SHA family which can be implemented extremely fast on cheap
32hardware.
33
34Installation
35============
36
37For Debian and Ubuntu, please ensure that the following packages are installed:
38
39.. code:: bash
40
41    $ sudo apt-get install build-essential libssl-dev python-dev
42
43For Fedora and RHEL-derivatives, please ensure that the following packages are installed:
44
45.. code:: bash
46
47    $ sudo yum install gcc openssl-devel python-devel
48
49For OSX, please do the following::
50
51    $ brew install openssl
52    $ export CFLAGS="-I$(brew --prefix openssl)/include $CFLAGS"
53    $ export LDFLAGS="-L$(brew --prefix openssl)/lib $LDFLAGS"
54
55For OSX, you can also use the precompiled wheels. They are installed by::
56
57    $ pip install scrypt
58
59For Windows, please use the precompiled wheels. They are installed by::
60
61    $ pip install scrypt
62
63For Windows, when the package should be compiled, the development package from https://slproweb.com/products/Win32OpenSSL.html is needed.
64It needs to be installed to C:\OpenSSL-Win64.
65
66You can install py-scrypt from this repository if you want the latest
67but possibly non-compiling version::
68
69    $ git clone https://github.com/holgern/py-scrypt.git
70    $ cd py-scrypt
71    $ python setup.py build
72
73    Become superuser (or use virtualenv):
74    # python setup.py install
75
76    Run tests after install:
77    $ python setup.py test
78
79Or you can install the latest release from PyPi::
80
81    $ pip install scrypt
82
83Users of the Anaconda_ Python distribution can directly obtain pre-built
84Windows, Intel Linux or macOS / OSX binaries from the conda-forge channel.
85This can be done via::
86
87    $ conda install -c conda-forge scrypt
88
89
90If you want py-scrypt for your Python 3 environment, just run the
91above commands with your Python 3 interpreter. Py-scrypt supports both
92Python 2 and 3.
93
94From version 0.6.0 (not available on PyPi yet), py-scrypt supports
95PyPy as well.
96
97Changelog
98=========
99
1000.8.18
101------
102* add wheel for python 3.9 and
103
1040.8.17
105------
106
107* add_dll_directory for python 3.8 on windows, as importlib.util.find_spec does not search all paths anymore
108
1090.8.16
110------
111
112* Add additional test vector from RFC (thanks to @ChrisMacNaughton)
113
1140.8.15
115------
116
117* Fix missing import
118
119
1200.8.14
121------
122
123* fix imp deprecation warning
124
125
1260.8.13
127------
128
129* improve build for conda forge
130
1310.8.12
132------
133
134* Add SCRYPT_WINDOWS_LINK_LEGACY_OPENSSL environment variable, when set, openssl 1.0.2 is linked
135
1360.8.11
137------
138
139* fix build for conda feedstock
140
1410.8.10
142------
143
144* fix typo
145
1460.8.9
147-----
148
149* use the static libcrypto_static for windows and openssl 1.1.1
150
1510.8.8
152-----
153
154* setup.py for windows improved, works with openssl 1.0.2 and 1.1.1
155
1560.8.7
157-----
158
159* setup.py for windows fixed
160
1610.8.6
162-----
163
164* setup.py fixed, scrypt could not be imported in version 0.8.5
165
1660.8.5
167-----
168
169* MANIFEST.in fixed
170* scrypt.py moved into own scrypt directory with __init__.py
171* openssl library path for osx wheel repaired
172
1730.8.4
174-----
175
176* __version__ added to scrypt
177* missing void in sha256.c fixed
178
1790.8.3
180-----
181
182* scrypt updated to 1.2.1
183* Wheels are created for python 3.6
184
185Usage
186=====
187
188Fore encryption/decryption, the library exports two functions
189``encrypt`` and ``decrypt``::
190
191    >>> import scrypt
192    >>> data = scrypt.encrypt('a secret message', 'password', maxtime=0.1) # This will take at least 0.1 seconds
193    >>> data[:20]
194    'scrypt\x00\r\x00\x00\x00\x08\x00\x00\x00\x01RX9H'
195    >>> scrypt.decrypt(data, 'password', maxtime=0.1) # This will also take at least 0.1 seconds
196    'a secret message'
197    >>> scrypt.decrypt(data, 'password', maxtime=0.05) # scrypt won't be able to decrypt this data fast enough
198    Traceback (most recent call last):
199      File "<stdin>", line 1, in <module>
200    scrypt.error: decrypting file would take too long
201    >>> scrypt.decrypt(data, 'wrong password', maxtime=0.1) # scrypt will throw an exception if the password is incorrect
202    Traceback (most recent call last):
203      File "<stdin>", line 1, in <module>
204    scrypt.error: password is incorrect
205
206From these, one can make a simple password verifier using the following
207functions::
208
209    def hash_password(password, maxtime=0.5, datalength=64):
210        return scrypt.encrypt(os.urandom(datalength), password, maxtime=maxtime)
211
212    def verify_password(hashed_password, guessed_password, maxtime=0.5):
213        try:
214            scrypt.decrypt(hashed_password, guessed_password, maxtime)
215            return True
216        except scrypt.error:
217            return False
218
219
220But, if you want output that is deterministic and constant in size,
221you can use the ``hash`` function::
222
223    >>> import scrypt
224    >>> h1 = scrypt.hash('password', 'random salt')
225    >>> len(h1)  # The hash will be 64 bytes by default, but is overridable.
226    64
227    >>> h1[:10]
228    '\xfe\x87\xf3hS\tUo\xcd\xc8'
229    >>> h2 = scrypt.hash('password', 'random salt')
230    >>> h1 == h2 # The hash function is deterministic
231    True
232
233
234Acknowledgements
235================
236
237Scrypt_ was created by Colin Percival and is licensed as 2-clause BSD.
238Since scrypt does not normally build as a shared library, I have included
239the source for the currently latest version of the library in this
240repository. When a new version arrives, I will update these sources.
241
242`Kelvin Wong`_ on Bitbucket provided changes to make the library
243available on Mac OS X 10.6 and earlier, as well as changes to make the
244library work more like the command-line version of scrypt by
245default. Kelvin also contributed with the unit tests, lots of cross
246platform testing and work on the ``hash`` function.
247
248Burstaholic_ on Bitbucket provided the necessary changes to make
249the library build on Windows.
250
251The `python-appveyor-demo`_ repository for setting up automated Windows
252builds for a multitude of Python versions.
253
254License
255=======
256
257This library is licensed under the same license as scrypt; 2-clause BSD.
258
259.. _scrypt: http://www.tarsnap.com/scrypt.html
260.. _Python: http://python.org
261.. _Burstaholic: https://bitbucket.org/Burstaholic
262.. _Kelvin Wong: https://bitbucket.org/kelvinwong_ca
263.. _python-appveyor-demo: https://github.com/ogrisel/python-appveyor-demo
264.. _Anaconda: https://www.continuum.io
265