Skip to content

UnknownCryptoError when encrypting #204

Answered by brycx
Jytesh asked this question in Q&A
Jun 4, 2021 · 2 comments · 11 replies
Discussion options

You must be logged in to vote

Hi!

If you take a peek at the errors documentation, you'll see that the first one says that the secret_key must be 32 bytes. The password you use here is however only 14 bytes. You can use the .len() function on a SecretKey instance to check if it is upheld. default() randomly generates 32 bytes, which is why it works.

In practice, please note that using user-passwords directly to encrypt data is not secure. You can use orion::kdf to "stretch" the password before using it for encryption. There is also an example in that module for this exact use-case.

Don't hesitate to let us know if there's anything else!

Replies: 2 comments 11 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
11 replies
@Jytesh
Comment options

@brycx
Comment options

brycx Jun 4, 2021
Maintainer

@Jytesh
Comment options

@Jytesh
Comment options

@Jytesh
Comment options

Answer selected by Jytesh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants