Php 4 Way To Encrypt And Decrypt Password Example

03-Apr-2023

.

Admin

Php 4 Way To Encrypt And Decrypt Password Example

Hi guys,

Today i will explained how to Encrypt And Decrypt Password In php to multiple ways. This example is so easy to use in php.

I am explaind to the 4 way to Encrypt And Decrypt passwod to explained. This Example to i am use in password_hash(),password_verify(),openssl_encrypt(),openssl_decrypt(),crypt(),hash_equals(),md5() all functions to use in example. So follow to my step by step.

So let's start to the example.

Example 1


<?php

$hash = password_hash('clear', PASSWORD_DEFAULT);

$ok = password_verify('clears', 'HASHED');

?>

Output

$2y$10$s8GQja9qVApgnURTFy1CHOqoEm8u1sh5fbEszXieDZbwZojOnlRQa

Example 2

<?php

$hash1 = openssl_encrypt("clear", "AES-128-ECB", "SECREARKEY");

$hash2 = openssl_decrypt("HASHED", "AES-128-ECB", "SECREARKEY");

?>

Output

285VrmWeatDdEH1WBGjPcw==

Example 3

<?php

$crypt = crypt("Clear Text");

$ok = hash_equals("HASHED",crypt("Clear","HASHED"));

?>

Output

$1$5X8gPwd9$w2iSc8Z70Uo8RoV1PD0rZ/

Example 4

<?php

$hash = md5("clear");

$has = md5("clear") == $hash;

print_r($hash);

// print_r($has);

?>

Output

-01bc6f8efa4202821e95f4fdf6298b30

-1

Now you can check your own.

I hope it can help you...

#PHP 8

#PHP