I'm trying to encode and decode a string using AES. At the moment, I'm encoding the string in Mono C# using the highest-rated answer here, because System.Security.Crytpography.Aes
is not available in Mono. However, this implementation uses a Salt, and the PHP method I'm using to decrypt it does not take a salt, only an Initialization Vector, which I generate.
My problem: The encrypted data is salted, and I don't know how to un-salt it even with the known salt string.
- Should I try to remove the salt from the C# class?
- Is the implementation good enough using only the plaintext, password/key, and initialization vector?
- Or is there another form of decryption that I can use in PHP that will take ciphertext, key, salt, and initialization vector?
- Or should I try to un-salt the decrypted text after calling
mcrypt_decrypt
on it? Is that the right order of things? - Or should I rewrite the C# AES class completely? Is it actually a bad example?
- [edit] Or does anyone know of a
Rfc2898DeriveBytes
implementation I can use in PHP? I'm not sure I'm confident enough to write the implementation myself, lest I completely defeat the point of security through some error.
Sorry for my ignorance, this is the first time I've ever dealt with encryption, and there's a lot of information to take in.