Skip to main content

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)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

strbcrypt-0.1.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

strbcrypt-0.1.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file strbcrypt-0.1.0.tar.gz.

File metadata

  • Download URL: strbcrypt-0.1.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for strbcrypt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 739f5667aa4190526aac405f5ae79fe6c18be565ecd26c5be9e35e87a320ab09
MD5 549f87d4ce9b9b33ecbd9c0616abe046
BLAKE2b-256 eb3247c17da26d30e794c0d14a81bc3641fe4ad01231458bdffeba462c4db442

See more details on using hashes here.

File details

Details for the file strbcrypt-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: strbcrypt-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for strbcrypt-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aa8c41f6fa93844a6c7ae9db0c5d391ccdc2dd95e7f54e98d7aa2c80881da2cf
MD5 08b73b534981d709ea1201cfa3271286
BLAKE2b-256 13c2ce1a221067ad0e245610eea023923c225d6f8dd73852bbb9c771cffc501b

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

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