Hello Today I saw you how to encrypt and decrypt password.
core PHP:
define ("SECRETKEY", "MyApplicationResult");
function encryptedPassword($password){
return openssl_encrypt($password, "AES-128-ECB", SECRETKEY);
}
function decryptedPassword($password){
return openssl_decrypt($password, "AES-128-ECB", SECRETKEY);
}
function encryptedPassword($password){
return openssl_encrypt($password, "AES-128-ECB", SECRETKEY);
}
function decryptedPassword($password){
return openssl_decrypt($password, "AES-128-ECB", SECRETKEY);
}
CodeIgniter 4:
public function encrypt_pass($simple_string){
// Store the cipher method
$ciphering = "AES-128-CTR";
// Use OpenSSl Encryption method
$iv_length = openssl_cipher_iv_length($ciphering);
$options = 0;
// Non-NULL Initialization Vector for encryption
$encryption_iv = '1234567891011121';
// Store the encryption key
$encryption_key = "MySecretKey";
return $encryption = openssl_encrypt($simple_string, $ciphering, $encryption_key, $options, $encryption_iv);
}
// Store the cipher method
$ciphering = "AES-128-CTR";
// Use OpenSSl Encryption method
$iv_length = openssl_cipher_iv_length($ciphering);
$options = 0;
// Non-NULL Initialization Vector for encryption
$encryption_iv = '1234567891011121';
// Store the encryption key
$encryption_key = "MySecretKey";
return $encryption = openssl_encrypt($simple_string, $ciphering, $encryption_key, $options, $encryption_iv);
}
public function decrypt_pass($encryption){
// Store the cipher method
$ciphering = "AES-128-CTR";
// Use OpenSSl Encryption method
$iv_length = openssl_cipher_iv_length($ciphering);
$options = 0;
// Non-NULL Initialization Vector for encryption
$decryption_iv = '1234567891011121';
// Store the encryption key
//$decryption_key = $this->websitekey;
$decryption_key = "MySecretKey";
return $decryption=openssl_decrypt ($encryption, $ciphering, $decryption_key, $options, $decryption_iv);
}
No comments:
Post a Comment