Skip to main content

pyscryptfirebase

A Python wrapper of Firebase's custom scrypt implementation. A combined fork of scrypt and Firebase scrypt.

Firebase scrypt for password hashing: https://github.com/firebase/scrypt

Python library for scrypt: https://bitbucket.org/mhallin/py-scrypt/src/default/

Instructions

Note that if you have the Python module scrypt installed, you will need to remove it to use this library. This library is a fork of scrypt and uses a modified C extension by the same name as scrypt. Using both libraries at the same time will cause a naming collision on the C module _scrypt.

Install dependencies according to your Python version and OS:

# Debian/Ubuntu
$ sudo apt-get install build-essential libssl-dev python-dev

# Fedora, RHEL
$ sudo yum install gcc openssl-devel python-devel

# Alpine Linux (Docker Containers)
$ apk add gcc openssl-dev python-dev

# (If you're on Python3, install the Python3 versions of the above packages)

# Mac
# Without setting the flags below, install will fail to find the necessary files
$ brew install openssl
$ export CFLAGS="-I$(brew --prefix openssl)/include $CFLAGS"
$ export LDFLAGS="-L$(brew --prefix openssl)/lib $LDFLAGS"

Then install pyscriptfirebase:

$ pip install pyscriptfirebase

Example

This module is intended to give the same output as the scrypt password hashing function that Firebase uses.

Firebase Scrypt Utility example:

# Params from the project's password hash parameters
base64_signer_key="jxspr8Ki0RYycVU8zykbdLGjFQ3McFUH0uiiTvC8pVMXAn210wjLNmdZJzxUECKbm0QsEmYUSDzZvpjeJ9WmXA=="
base64_salt_separator="Bw=="
rounds=8
memcost=14

# Params from the exported account
base64_salt="42xEC+ixf3L2lw=="

# The users raw text password
password="user1password"

# Generate the hash
# Expected output:
# lSrfV15cpx95/sZS2W9c9Kp6i/LVgQNDNC/qzrCnh1SAyZvqmZqAjTdn3aoItz+VHjoZilo78198JAdRuid5lQ==
echo `./scrypt "$base64_signer_key" "$base64_salt" "$base64_salt_separator" "$rounds" "$memcost" -P <<< "$password"`

pyscryptfirebase example:

import base64

import pyscryptfirebase


base64_signer_key = base64.b64decode("jxspr8Ki0RYycVU8zykbdLGjFQ3McFUH0uiiTvC8pVMXAn210wjLNmdZJzxUECKbm0QsEmYUSDzZvpjeJ9WmXA==")
base64_salt_separator = base64.b64decode("Bw==")
rounds = 8
memcost = 14

base64_salt = base64.b64decode("42xEC+ixf3L2lw==")
password = "user1password"

# Expected output:
# lSrfV15cpx95/sZS2W9c9Kp6i/LVgQNDNC/qzrCnh1SAyZvqmZqAjTdn3aoItz+VHjoZilo78198JAdRuid5lQ==
output = pyscryptfirebase.encrypt(
    base64_signer_key,
    base64_salt,
    base64_salt_separator,
    rounds,
    memcost,
    password
)
encoded_output = base64.b64encode(result)
print(encoded_output)

Metadata

Release files for pyscryptfirebase 0.0.2

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

Source distribution (sdist)

Source distribution for pyscryptfirebase 0.0.2
File Size Uploaded Provenance Actions
pyscryptfirebase-0.0.2.tar.gz 41.4 kB Without provenance Details for pyscryptfirebase-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyscryptfirebase 0.0.2
File Interpreter ABI Platform Actions
pyscryptfirebase-0.0.2-cp38-cp38-macosx_10_14_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.14+ x86-64 Details for pyscryptfirebase-0.0.2-cp38-cp38-macosx_10_14_x86_64.whl

Total release size: 61.6 kB

Release files / pyscryptfirebase-0.0.2.tar.gz

Download URL pyscryptfirebase-0.0.2.tar.gz
Size 41.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a81f3336fd391a3161a63cfa77d7a517eb23e599b333528b036a933ef32d95f7
BLAKE2b-256 checksum
How to use checksums
eb26982aa8e5de7edf3696e278c3ef5b52c663b0a2e5691b90bf84195016c759
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.1

Release files / pyscryptfirebase-0.0.2-cp38-cp38-macosx_10_14_x86_64.whl

Download URL pyscryptfirebase-0.0.2-cp38-cp38-macosx_10_14_x86_64.whl
Size 20.2 kB
Tags CPython 3.8 macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
32a912b396d4b470ccdc29ffc337cfc6550ecdfe43dac9121486bc5d366237eb
BLAKE2b-256 checksum
How to use checksums
42dd87f3bc0481d7363f2731dc96b7c599d655f4ab9fa49ee25143cbe63b3aab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.1

Security for pyscryptfirebase 0.0.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.0.2 This release

2 release files No provenance

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