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

Posted on 2009-04-22
Last Modified: 2013-11-10
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.
Question by:htn5ca
    1 Comment
    LVL 2

    Accepted 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

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
    Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now