Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4272
  • Last Modified:

How to encrypt a file using PHP with AES 256-bit

I was wondering if someone could get me start on wrong some php code to encrypt a file with AES.  I will be writing some C# code to decrypt the file but I am familiar with C# and not very familiar with PHP.
1 Solution
Hi htn5ca,

I've not tested this, but you could take a look at the following, it may help (it's a PHP class doing AES encryption):

Keep in mind though that encryption implementations are not consistent across languages.  For example, even if this may work for you in PHP, it may not decrypt in C# for example.

The only articles I've found coming to a fully working solution to this (C# and PHP combo) use the TripleDES algorithm (which is still considered safe as far as I know):


The second article complements the first.  If you want a fast working solution, the above articles will help you setup a TripleDES encryption scheme really quickly.  If going with AES is a requirement for you, I would be interested in seeing your implementation if you manage to implement one.

Hope this helps...

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now