#PHP

Writing C#’s Rfc2898DeriveBytes in PHP

Recently I came across a third party backend writen in C# that encrypted small pieces of sensible data for storing in the database with AES-256-CBC. The piece of code responsible for the encryption and decryption can be found at the bitlush blog (kudos to the authors). This backend would send this encrypted information to our backend system writen in PHP, and it was our responsability to decrypt those pieces of data on our end, and so we had to effectively at least write the decrypt function exactly the same way as the C#’s counterpart.