How can I encrypt with AES in C# so I can decrypt it in PHP? -
i've found few answers encrypt in php, , decrypt in c#, yet have been unable reverse process...
the background want to:
in c#: aes encrypt file's contents. upload data (likely via http via post) server.
in php: receive , save file.
and in php (at later date): decrypt file.
i want encrypt outside of using ssl/tls (though might have well), need know file remains encrypted (and decryptable!) when stored on server.
to encrypt in c# i'm using:
rijndael rijndaelalg = rijndael.create(); rijndaelalg.keysize = 128; rijndaelalg.mode = ciphermode.cbc; cryptostream cstream = new cryptostream(fstream, rijndaelalg.createencryptor(key, iv), cryptostreammode.read);
and decrypt in php:
mcrypt_cbc(mcrypt_rijndael_128, $key, $buffer, mcrypt_decrypt, $iv);
generally depends on selecting right options on both sides:
plaintext character format
how plaintext characters encoded in bit string
-
how pad plaintext exact multiple of block size
key length
must agreed if there choice
-
how create bit string used key
mode
which mode of encryption use
-
how store ciphertext
please see here lot of information these things. padding seems root of interoperability problems php's mcrypt
uses null
-padding default , has no built-in support other padding mode, while e.g. .net doesn't provide option use null
-padding (as may cause issues when encrypting binary data).
Comments
Post a Comment