Add encrypt/decrypt support
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5809 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
42
Tests/encryptTest.php
Normal file
42
Tests/encryptTest.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/** DomFramework - Tests
|
||||
* @package domframework
|
||||
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||
*/
|
||||
|
||||
/** Test the encrypt.php file */
|
||||
class encryptTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/** Check the length of the otken with cipher
|
||||
*/
|
||||
public function testEncrypt1 ()
|
||||
{
|
||||
$encrypt = new encrypt ();
|
||||
$res = $encrypt->encrypt ("TextToEncode",
|
||||
"123456789012345678901234");
|
||||
$this->assertSame (strlen ($res), 24);
|
||||
}
|
||||
|
||||
/** Check if the encrypt/decrypt process return the same result
|
||||
*/
|
||||
public function testEncrypt2 ()
|
||||
{
|
||||
$encrypt = new encrypt ();
|
||||
$payload = "TextToEncode";
|
||||
$ckey = "123456789012345678901234";
|
||||
$token = $encrypt->encrypt ($payload, $ckey);
|
||||
$res = $encrypt->decrypt ($token, $ckey);
|
||||
$this->assertSame ($res, $payload);
|
||||
}
|
||||
|
||||
/** Check if the encrypted part is well unreadable
|
||||
*/
|
||||
public function testEncrypt3 ()
|
||||
{
|
||||
$encrypt = new encrypt ();
|
||||
$payload = "TextToEncode";
|
||||
$token = $encrypt->encrypt ($payload, "123456789012345678901234");
|
||||
$res = strpos ($token, "Text");
|
||||
$this->assertSame ($res, false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user