Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Hold on, in the Rust example, how does `err_on_truncation` get set? TFA completely ignored that there's a setting somewhere (probably incorrectly defaulting to false)


In the bcrypt crate there is an explicit method for it:

    bcrypt::non_truncating_hash() 
https://docs.rs/bcrypt/latest/bcrypt/

Funnily, TFA later also suggests that such function should exist...


Being pedantic, TFA suggests something slightly different. The non_truncating_hash should be the default (and called something that reflects it, eg. just hash), and a separate truncating_hash function may exist. The difference (from an API design perspective) is pretty massive.


the rust library exposes a handful of "non_truncating_*" functions that enable error handling. i would expect this to be for drop-in compatibility with old code.

amusingly, the python "library" is just a thin wrapper around the same rust library.

protip: a lot of cryptography primitives actually aren't that complicated in terms of the code itself (and often can be quite elegant, compact and pleasing to the eye). if it's important, probably worth just reading it.

it's what people wrap them with or the systems they build that get messy!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: