Recommend this page to a friend! |
EnCryptDe | > | All threads | > | Wrong results | > | (Un) Subscribe thread alerts |
|
|
![]() Hi.
I just downloaded your class and tested with some other data and got wrong results back. Just run this script and see the results. <?php /** * Newest version always at * https://gist.github.com/1395302 */ define('BR',"<br />\n"); include 'Crypter.php'; $Crypter = new Crypter(); $key = 'LbCgRj6uIcOaqvWmZQV253l9Hk0MxeSfDUEFt7yiGr4z1YXAhopTNJBnw'; $Crypter->setScramble2($key); $str = 'Pure php enCrypt, deCrypt strings'; echo "<p style='margin:0px;'>Your key: $key</p>"; echo "<p style='margin:0px;'>Your string: $str</p>"; $str = $Crypter->encrypt($str); echo "<p style='margin:0px;'>encrypt result:(<span style='font-weight:bold;'>$str</span>)</p>"; echo "<p style='margin:0px;'>Result after decryption:(<span style='font-weight:bold;'>{$Crypter->decrypt($str)}</span>)</p>"; echo "<p style='margin:0px;font-size:24px;'>Perfect Result</p>"; echo BR.BR; $str = 'ThisIsSomeDataToTest.something.com.EndDataToTest'; echo "<p style='margin:0px;'>First I tryed some other data with your key</p>"; echo "<p style='margin:0px;'>Original Data:(<span style='font-weight:bold;'>$str</span>)</p>"; $str = $Crypter->encrypt( $str ); echo "<p style='margin:0px;'>encrypt result:(<span style='font-weight:bold;'>$str</span>)</p>"; echo "<p style='margin:0px;'>Result after decryption:(<span style='font-weight:bold;'>{$Crypter->decrypt( $str )}</span>)</p>"; echo "<p style='margin:0px;font-size:24px;'>Wrong Result</p>"; echo BR.BR; $str = 'Version20101205%@@%Method=POST%@@%Gets=%@@%Prog=SiteSecurity/UserSignOn.php%@@%Chain=6%@@%Next=2%@@%Post=commonNewLang=Es,commonSessKeep=,commonUpdate=Continue,commonBasic=6,commonOrder=1,formIdNumber=3238071,formPassword=,formPasswordMd5=c8a957ee2bf49989341b998b849a9e0b,formVideoKey=,formVideoKeyMd5=%@@%Referer=/VideoHipico/SiteSecurity/UserSignOn.php%@@%RefType=Normal%@@%End=End'; echo "<p style='margin:0px;'>This is a very long string to see just what happens with your key</p>"; echo "<p style='margin:0px;'>Original Data:(<span style='font-weight:bold;'>$str</span>)</p>"; $str = $Crypter->encrypt( $str ); echo "<p style='margin:0px;'>encrypt result:(<span style='font-weight:bold;'>$str</span>)</p>"; echo "<p style='margin:0px;'>Result after decryption:(<span style='font-weight:bold;'>{$Crypter->decrypt( $str )}</span>)</p>";; echo "<p style='margin:0px;font-size:24px;'>Wrong Result</p>"; echo BR.BR; $key = 'abcdefghijklmnopqrstuvewxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ.-,;:_'; echo "<p style='margin:0px;'>I thought that maybe there are characters missing in the encryption key so I changed the key to</p>"; echo "<p style='margin:0px;'>$key</p>"; $Crypter->setScramble2($key); $str = 'ThisIsSomeDataToTest.something.com.EndDataToTest'; echo "<p style='margin:0px;'>First I tryed some other data with the modyfied key</p>"; echo "<p style='margin:0px;'>Original Data:(<span style='font-weight:bold;'>$str</span>)</p>"; $str = $Crypter->encrypt( $str ); echo "<p style='margin:0px;'>encrypt result:(<span style='font-weight:bold;'>$str</span>)</p>"; echo "<p style='margin:0px;'>Result after decryption:(<span style='font-weight:bold;'>{$Crypter->decrypt( $str )}</span>)</p>"; echo "<p style='margin:0px;font-size:24px;'>ALSO Wrong Result</p>"; echo BR.BR; $str = 'Version20101205%@@%Method=POST%@@%Gets=%@@%Prog=SiteSecurity/UserSignOn.php%@@%Chain=6%@@%Next=2%@@%Post=commonNewLang=Es,commonSessKeep=,commonUpdate=Continue,commonBasic=6,commonOrder=1,formIdNumber=3238071,formPassword=,formPasswordMd5=c8a957ee2bf49989341b998b849a9e0b,formVideoKey=,formVideoKeyMd5=%@@%Referer=/VideoHipico/SiteSecurity/UserSignOn.php%@@%RefType=Normal%@@%End=End'; echo "<p style='margin:0px;'>This is a very long string to see just what happens with your key</p>"; echo "<p style='margin:0px;'>Original Data:(<span style='font-weight:bold;'>$str</span>)</p>"; $str = $Crypter->encrypt( $str ); echo "<p style='margin:0px;'>encrypt result:(<span style='font-weight:bold;'>$str</span>)</p>"; echo "<p style='margin:0px;'>Result after decryption:(<span style='font-weight:bold;'>{$Crypter->decrypt( $str )}</span>)</p>";; echo "<p style='margin:0px;font-size:24px;'>ALSO Wrong Result</p>"; echo BR.BR; ?>
![]() Hi!
The problem is quite simple - your $key is too short. Just make sure that $key is at least as long as RTCrypt::streight is - and you'll get correct results. Have a nice coding! |
info at phpclasses dot org
.