Skip to content

Implement unicode support for lazily encoding strings - #1246

Open
Vizonex wants to merge 1 commit into
pyca:mainfrom
Vizonex:unicode-support
Open

Implement unicode support for lazily encoding strings#1246
Vizonex wants to merge 1 commit into
pyca:mainfrom
Vizonex:unicode-support

Conversation

@Vizonex

@Vizonex Vizonex commented Aug 11, 2026

Copy link
Copy Markdown

Something I've come across when using this library is wanting to make things easier for users hashpw(password.encode('utf-8'), ...) can be rather annoying and I hope this PR tries to optimize some of the brokenness with unicode support. I'm sure the example I've given logically illustrates what I am after.

from fastapi import FastAPI
from bcrypt import checkpw_from_string

app = FastAPI()

@app.post("/login")
def login(username:str, password:str):
        # SQL Query performed and is fetching the username and bcrypt hash
        ... = checkpw_from_string(password, _hash)

@alex

alex commented Aug 11, 2026

Copy link
Copy Markdown
Member

KDFs operate over byte strings, unless the KDF itself defines an encoding for strings, I think offering this API is a mistake, because it misleads users into not understanding what level of abstraction things operate at. The extremely modest inconveience of having to encode your string is worth it to keep thing conceptually correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants