Encryption File Encrypted Messenger PHP
Encryption File
Encrypted Messenger PHP
password_hash
password_hash() creates a new password hash using a strong one-way hashing algorithm.
password_hash() is compatible with crypt().
Therefore, password hashes created by crypt() can be used with password_hash().
base64_decode
base64_decode — Decodes data encoded with MIME base64
hash_hmac
hash_hmac — Generate a keyed hash value using the HMAC method
openssl_cipher_iv_length
Gets the cipher initialization vector (iv) length.
openssl_encrypt
Encrypts given data with given method and key, returns a raw or base64 encoded string
substr
Returns the portion of string specified by the start and length parameters.
openssl_decrypt
Takes a raw or base64 encoded string and decrypts it using a given method and key.
hash_equals
Compares two strings using the same time whether they’re equal or not.
This function should be used to mitigate timing attacks; for instance, when testing crypt() password hashes.
ctype_digit
Checks if all of the characters in the provided string, text, are numerical.
Create a file named secured-encryption.php
<?php
//***********************************************************************************************
function gns_hash_pro($a)
{
$b = password_hash( $a , PASSWORD_DEFAULT );
return $b;
}
//***********************************************************************************************
function gns_hash_fix($a)
{
$k = base64_decode(XTHIRDXKEYX);
$y = base64_decode(XFOURTHXKEYX);
$h = hash_hmac('sha3-512', $a, $k, TRUE);
if($h == FALSE)
die("This is Secured By Omid Bahrami");
$x = hash_hmac('sha3-512', $h, $y);
if($x == FALSE)
die("This is Secured By Omid Bahrami");
return $x;
}
//***********************************************************************************************
function gns_encode($a)
{
$k = base64_decode(XFIRSTXKEYX);
$y = base64_decode(XSECONDXKEYX);
$x = "aes-256-cbc";
$n = openssl_cipher_iv_length($x);
$i = openssl_random_pseudo_bytes($n);
$b = openssl_encrypt($a,$x,$k, OPENSSL_RAW_DATA ,$i);
if($b == FALSE)
die("This is Secured By Omid Bahrami");
$c = hash_hmac('sha3-512', $b, $y, TRUE);
if($c == FALSE)
die("This is Secured By Omid Bahrami");
$d = base64_encode( $i.$c.$b );
return $d;
}
//***********************************************************************************************
function gns_decode($a)
{
$k = base64_decode(XFIRSTXKEYX);
$y = base64_decode(XSECONDXKEYX);
$f = base64_decode($a);
$x = "aes-256-cbc";
$n = openssl_cipher_iv_length($x);
$i = substr($f, 0, $n);
$c = substr($f, $n,64);
$b = substr($f , $n + 64);
$x = openssl_decrypt($b,$x,$k,OPENSSL_RAW_DATA,$i);
if($x == FALSE)
die("This is Secured By Omid Bahrami");
$cx = hash_hmac('sha3-512', $b, $y, TRUE);
if($cx == FALSE)
die("This is Secured By Omid Bahrami");
if (hash_equals($c,$cx))
return $x;
die("This is Secured By Omid Bahrami");
}
//***********************************************************************************************
function gns_encode_invisible($a)
{
$k = $_SESSION["xkeyx"] ;
$b = $a * $k ;
return $b;
}
//***********************************************************************************************
function gns_decode_invisible($a)
{
if(! ctype_digit($a) )
die("This is Secured By Omid Bahrami");
$k = $_SESSION["xkeyx"] ;
$b = $a / $k ;
return $b;
}
//***********************************************************************************************
function gns_hash_xvx($a)
{
$k = base64_decode(XFIFTHXKEYX);
$y = base64_decode(XSIXTHXKEYX);
$h = hash_hmac('sha3-512', $a, $k, TRUE);
if($h == FALSE)
die("This is Secured By Omid Bahrami");
$x = hash_hmac('sha3-512', $h, $y);
if($x == FALSE)
die("This is Secured By Omid Bahrami");
return $x;
}
//***********************************************************************************************
function gns_hash_xxvxx($a)
{
$k = base64_decode(XSEVENTHXKEYX);
$y = base64_decode(XEIGHTHXKEYX);
$h = hash_hmac('sha3-512', $a, $k, TRUE);
if($h == FALSE)
die("This is Secured By Omid Bahrami");
$x = hash_hmac('sha3-512', $h, $y);
if($x == FALSE)
die("This is Secured By Omid Bahrami");
return $x;
}
//***********************************************************************************************
function gns_hash_xxxvxxx($a)
{
$b = password_hash( $a , PASSWORD_DEFAULT );
return $b;
}
//***********************************************************************************************
?>
Full structure is available at Encrypted Messenger PHP