Re: Encryption failing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Jan 15, 2008, at 11:08 PM, Andrés Robinet wrote:

I second that, you should base64 encode values before encrypting and base64
decode them after decrypting to be safe.

Thanks for the idea.

Like this? Fails 500/500 times on my test.

------------------------------------
if ($EorD == "D") {
	$text_out = mdecrypt_generic($cypher,$text);
	$text = base64_decode($text);
} else {
	$text= base64_encode($text);
	$text_out = mcrypt_generic($cypher,$text);
} // endif ($EorD == "D")
------------------------------------

A quick test looks like this:

1: String: 9334133814260182
 -|- Enc: X5Þ©·ža`p#È]#c¦±3ÔýCõÒiÏ~r¢Tª"
 -|- Dec:OTMzNDEzMzgxNDI2MDE4Mg== -|- Nope

2: String: 3027022406512648
 -|- Enc: j£n,h\"mê´ uKP%¥†¼D}H‚’f¢š„
 -|- Dec:MzAyNzAyMjQwNjUxMjY0OA== -|- Nope

3: String: 5042504153020331
 -|- Enc: 9ÿ•ýŸÝ§¤6Wi+€×Ÿéáo>nñº*J6}Ø+„
 -|- Dec:NTA0MjUwNDE1MzAyMDMzMQ== -|- Nope

4: String: 6741156238850410
 -|- Enc: ·:´[Úq\‹ë‹4\Q«ÍŽ5±{º‡µØtþðtN?b
 -|- Dec:Njc0MTE1NjIzODg1MDQxMA== -|- Nope

5: String: 0003100244041329
 -|- Enc: D¾¤úV:!Mû4ƒÜ€àœ‰ŽòÐÐ^ïHñ-š%z
 -|- Dec:MDAwMzEwMDI0NDA0MTMyOQ== -|- Nope

Wrong: 5/5

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux