Decrypting file using pbkdf2

hi i use this crate pbkdf2 to encrypt a file the file got encrypted now i want it to get decrypted , what is the way to decrypt the file using pbkdf2

my toml file
pbkdf2 = { version = "0.12.2",features = ["simple"]}

i could not see any decryption methods there

As its very name implies, PBKDF is a KDF, a key derivation function. It's a hash function – it doesn't encrypt anything, and it's not (realistically) invertible. Whatever you did with PBKDF wasn't encryption, it was hashing.

You can use PBKDF to generate a key used for symmetric encryption and decryption, but how you use that key is beyond the responsibility and capabilities of PBKDF.

1 Like

This gives you a key. You'll need to give this key to an appropriate encryption algorithm.

If you already have an encrypted file, check exactly what algorithm and block mode it needs. You'll get garbage if you don't match existing algorithm exactly.

If you're writing something from scratch, check AES and ChaCha.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.