1

I'm attempting to use this encryption system with PHP.

It comes with this code from the download.

$salt = 'nala321';
$password = 'Alan';
 include('./crypt/Crypt/AES.php');
 $aes = new Crypt_AES();
 $aes->setKey('abcdefghijklmn');

 $size = 10 * 1024; 

***EDIT***
 $plaintext = $password.$salt;
***EDIT***

 for ($i = 0; $i < $size; $i++) {
     $plaintext.= 'a';
 }
 $enc = $aes->encrypt($plaintext);
 echo $enc;

This results in a very long output. How do I go about storing this into mysql? I've looked at different ideas saying to do

EDIT

It returns characters like this

¸ÂØwÕ·›óöŽfjËëªû ÒÚCÂF I3T{öËY_Œ:4$¯Ÿ´

EDIT

VARCHAR(16) CHARSET ascii COLLATE ascii_bin

Which is for an md5 encryption password. I'm not sure if I should put down the size to

$size = (16*16)-1; // for 255 limit on varchar

Thanks for the comments to come!

10
  • 1
    You should really hash passwords rather than encrypt them... Commented May 30, 2012 at 0:15
  • It's in the sake of the question. I do salt them. Commented May 30, 2012 at 0:17
  • If you do encryption right you can have essentially a military grade salted hash. Commented May 30, 2012 at 0:20
  • 1
    its only a salt if used for one way hashing Commented May 30, 2012 at 0:20
  • 2
    If it's solved, post an answer, and accept it, instead of editing *SOLVED* into the title. Commented May 30, 2012 at 21:29

1 Answer 1

1

I took out the for loop entirely.

Stored the password as just a varchar(30) and it works just fine.

The final codes looks like this

$password = 'Alan';
include('./crypt/Crypt/AES.php');
$aes = new Crypt_AES();
$aes->setKey('abcdefghijklmn');
$enc = $aes->encrypt($plaintext);
echo $enc;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.