Encryption & Decryption using PHP


<pre>
//Encryption
function encryption_function($string){
	// Storingthe cipher method 
	$ciphering = "AES-128-CTR";

	// Using OpenSSl Encryption method 
	$iv_length = openssl_cipher_iv_length($ciphering);
	$options   = 0;

	// Non-NULL Initialization Vector for encryption 
	$encryption_iv = '0000111122223333';

	// Storing the encryption key 
	$encryption_key = "aviweb";
	
	return openssl_encrypt($string, $ciphering, $encryption_key, $options, $encryption_iv);
}
//Decryption
function decryption_function($string){
	// Storingthe cipher method 
	$ciphering = "AES-128-CTR";

	// Using OpenSSl Encryption method 
	$iv_length = openssl_cipher_iv_length($ciphering);
	$options   = 0;

	// Non-NULL Initialization Vector for encryption 
	$decryption_iv = '0000111122223333';

	// Storing the decryption key 
	$decryption_key = "aviweb";
	
	return openssl_decrypt($string, $ciphering, $decryption_key, $options, $decryption_iv);
}
</pre>
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s