forked from DrHazemAli/PHP-Class-Encryption-Algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.php
More file actions
56 lines (46 loc) · 1.84 KB
/
Test.php
File metadata and controls
56 lines (46 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/**
* Encryption Algorithms
* Written By : Dr. Hazem Ali
* https://www.fb.com/Haz4m
* Date: 01/12/2016
* Time: 5:00 AM
* License : GNU GENERAL PUBLIC LICENSE
*/
require("Encryption.php");
/*
if you want to change the encryption method, key or IV
you can do it by passing the new parameters when
the encryption class being called.
e.g. : $encryption = new Encryption("METHID", "KEY", "IV");
*/
// Initialize Class with the default settings.
$Encryptor = new Encryption();
//--------------------------------------------//
/* Encrypt String Test */
$EncryptedString = $Encryptor->Encrypt("Hello World");
echo "ENCRYPTED STRING :> {$EncryptedString} \r\n";
//--------------------------------------------//
//--------------------------------------------//
/* Decrypt String Test
* PLEASE DO NOT PERFORM THIS CALL IF THE PASSED
* PARAMETER IS NOT ENCRYPTED */
$EncryptedString = "WDBmZlZodU4zd2hCNkpqRjNCOXhndz09";
$DecryptedString = $Encryptor->Decrypt($EncryptedString);
echo "DECRYPTED STRING :> {$DecryptedString} \r\n";
//--------------------------------------------//
/* --------------- PASSWORD ENCRYPTION ---------------*
* THE ENCRYPTION CLASS DESIGNED TO PERFORM THE MAX.
* ENCRYPTION FOR PASSWORDS, WHICH CANNOT BE DECRYPTED
* IN ORDER TO ENCRYPT A PASSWORD, PLEASE CALL THIS FUNC.
*/
$Password = "123456";
$EncryptedPassword = $Encryptor->EncryptPassword($Password);
echo "ENCRYPTED PASSWORD :> {$EncryptedPassword} \r\n";
/* YOU CAN PERFORM THE PASSWORD EQUALITY (IF STATEMENT)
* by using the condition below : */
if ($Encryptor->EncryptPassword($Password) == $EncryptedPassword)
{
// Password is Correct ....
}else { /* Password is not correct. */ }
// --------------------------------------------------//