StrBcrypt
A Wrapper for the bcrypt python library that acts as a lazy shortcut for fastapi and other applications that need to hash password and verify them.
Why
-
the python bcrypt developers do not have any intrest in adding lazy string support so I went ahead and did it with very minimal time spent.
-
Too many users wind up using bcrypt with in their favorite server wrappers together. Most post requests wind up using passwords in string format. This libary attempts to eliminate a problem with needing to encode absolutely everything under the sun keeping your code nice and clean. You can inject StrBcrypt as a dependency in your litestar projects as well as fastapi very easily.
Installation
pip install strbcrypt
Using StrBcrypt
To utilize it is written in an object oriented format to make up for the different settings a user may wind up utilitizing.
from strbcrypt import StrBcrypt
utf8_bcrypt = StrBcrypt("utf-8", errors="surrogateescape", rounds=11)
def main():
pwd = "password"
bcrypt_hash = utf8_bcrypt.hashpw(pwd)
if utf8_bcrypt.checkpw(pwd, bcrypt_hash):
print("success")
else:
print("WRONG!")
if __name__ == "__main__":
main()
Going Async
This library also provides an asynchronous wrapper if that in any way is important to you.
pip install strbcrypt[anyio]
import anyio
from strbcrypt.anyio import AsyncStrBcrypt
utf8_bcrypt = AsyncStrBcrypt("utf-8", errors="surrogateescape", rounds=11)
async def main():
pwd = "password"
bcrypt_hash = await utf8_bcrypt.hashpw(pwd)
if await utf8_bcrypt.checkpw(pwd, bcrypt_hash):
print("success")
else:
print("WRONG!")
if __name__ == "__main__":
anyio.run(main)
Metadata
Release files for strbcrypt 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| strbcrypt-0.1.0.tar.gz | 7.7 kB | Without provenance | Details for strbcrypt-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| strbcrypt-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for strbcrypt-0.1.0-py3-none-any.whl |
Total release size: 15.8 kB
Release files / strbcrypt-0.1.0.tar.gz
| Download URL | strbcrypt-0.1.0.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
739f5667aa4190526aac405f5ae79fe6c18be565ecd26c5be9e35e87a320ab09
|
|
BLAKE2b-256 checksum How to use checksums |
eb3247c17da26d30e794c0d14a81bc3641fe4ad01231458bdffeba462c4db442
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / strbcrypt-0.1.0-py3-none-any.whl
| Download URL | strbcrypt-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aa8c41f6fa93844a6c7ae9db0c5d391ccdc2dd95e7f54e98d7aa2c80881da2cf
|
|
BLAKE2b-256 checksum How to use checksums |
13c2ce1a221067ad0e245610eea023923c225d6f8dd73852bbb9c771cffc501b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for strbcrypt 0.1.0
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.