encrypt decrypt php

Solutions on MaxInterview for encrypt decrypt php by the best coders in the world

showing results for - "encrypt decrypt php"
Leni
17 Apr 2018
1function encrypt_decrypt($string, $action = 'encrypt')
2{
3    $encrypt_method = "AES-256-CBC";
4    $secret_key = 'AA74CDCC2BBRT935136HH7B63C27'; // user define private key
5    $secret_iv = '5fgf5HJ5g27'; // user define secret key
6    $key = hash('sha256', $secret_key);
7    $iv = substr(hash('sha256', $secret_iv), 0, 16); // sha256 is hash_hmac_algo
8    if ($action == 'encrypt') {
9        $output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
10        $output = base64_encode($output);
11    } else if ($action == 'decrypt') {
12        $output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
13    }
14    return $output;
15}
16 
17echo "Your Encrypted password is = ". $pwd = encrypt_decrypt('spaceo', 'encrypt');
18echo "Your Decrypted password is = ". encrypt_decrypt($pwd, 'decrypt');
19
Deidre
12 May 2018
1function encryptPass($password) {
2    $sSalt = '20adeb83e85f03cfc84d0fb7e5f4d290';
3    $sSalt = substr(hash('sha256', $sSalt, true), 0, 32);
4    $method = 'aes-256-cbc';
5
6    $iv = chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0);
7
8    $encrypted = base64_encode(openssl_encrypt($password, $method, $sSalt, OPENSSL_RAW_DATA, $iv));
9    return $encrypted;
10}
11
12function decryptPass($password) {
13    $sSalt = '20adeb83e85f03cfc84d0fb7e5f4d290';
14    $sSalt = substr(hash('sha256', $sSalt, true), 0, 32);
15    $method = 'aes-256-cbc';
16
17    $iv = chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0);
18
19    $decrypted = openssl_decrypt(base64_decode($password), $method, $sSalt, OPENSSL_RAW_DATA, $iv);
20    return $decrypted;
21}
Adelia
03 May 2016
1function encryptor($action, $string) {
2	$output = FALSE;
3	$encrypt_method = "AES-256-CBC";
4	$secret_key = 'SecretKeyWord';
5	$secret_iv  = 'SecretIV@123GKrQp';
6	// hash
7	$key = hash('sha256', $secret_key);
8	// iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning
9	$iv = substr(hash('sha256', $secret_iv), 0, 16);
10	//do the encryption given text/string/number
11	if ($action == 'encrypt') {
12		$output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
13		$output = base64_encode($output);
14	} elseif ($action == 'decrypt') {
15		//decrypt the given text/string/number
16		$output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
17	}
18	return $output;
19}
20
21function encrypt($data) {
22	return urlencode(self::encryptor('encrypt', self::sanitize($data)));
23}
24
25function decrypt($data) {
26	return self::encryptor('decrypt', urldecode(self::sanitize($data)));
27}
28// Now you can just call encrypt($string) or decrypt($string)
29?>
Lucia
26 Aug 2017
1function encrypt($plaintext, $password) {
2    $method = "AES-256-CBC";
3    $key = hash('sha256', $password, true);
4    $iv = openssl_random_pseudo_bytes(16);
5
6    $ciphertext = openssl_encrypt($plaintext, $method, $key, OPENSSL_RAW_DATA, $iv);
7    $hash = hash_hmac('sha256', $ciphertext . $iv, $key, true);
8
9    return $iv . $hash . $ciphertext;
10}
11
12function decrypt($ivHashCiphertext, $password) {
13    $method = "AES-256-CBC";
14    $iv = substr($ivHashCiphertext, 0, 16);
15    $hash = substr($ivHashCiphertext, 16, 32);
16    $ciphertext = substr($ivHashCiphertext, 48);
17    $key = hash('sha256', $password, true);
18
19    if (!hash_equals(hash_hmac('sha256', $ciphertext . $iv, $key, true), $hash)) return null;
20
21    return openssl_decrypt($ciphertext, $method, $key, OPENSSL_RAW_DATA, $iv);
22}
23
24//Example usage:
25$encrypted = encrypt('Plaintext string.', 'password'); // this yields a binary string
26
27echo decrypt($encrypted, 'password');
28// decrypt($encrypted, 'wrong password') === null
Martina
27 Sep 2020
1//Key
2$key = 'SuperSecretKey';
3
4//To Encrypt:
5$encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, 'I want to encrypt this', MCRYPT_MODE_ECB);
6
7//To Decrypt:
8$decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $encrypted, MCRYPT_MODE_ECB);
9
Victoria
30 May 2018
1$decoded = base64_decode($encoded);
2
queries leading to this page
decode and encode messages decrypt and encrypt phpdecrypt to encrypt php onlineencrypt decrypt file phpphp encrypt unencrypt with keyencrypt and decrypt string in phphow to encrypt password in phpphp encrypt decrypt functiondatabase encrypted password decrypted to match in phpencryption phpencrypt decrypt string in phpphp encrypt decrypt intphp encode with keypassword decryption in phpeasy php encryption decryptionphp best encryption and decryptionpgp encryption and decryption phpfast random encryption in phpphp how to encrypt text with a saltencrypt data in phpphp easily encrypt and decrypt dataencrypt and decrypt using phpphp rijndael encrypt 2fdecryptadd encryption to text in phpencrypt string in phpphp simple encrypt decrypthow to encrypt data in phphow to make text encrypt and decrypt phpphp code to encrypt and decrypt passwordencryption and decryption phpdecrypt crypt 28 29 password in written in phpdecrypt crypt function phpjava encrypt decrypt in phpphp crypt encrypt decrypthow to decrypt php passwordencrypt a string using decrypt key in phpphp unsafe encryptionphp hash password decryptwhat other methods can i use to encrypt and decrypt a string using phpdecrypt data phphash decrypt phpencrypt en decrypt phpencryption php passwordphp aes encrypt 2f decryptencrypt and decrypt data in php encrypt with key phpencrypt and decrypt id in phpphp crypt function decryptdecrypt password php mysqlaes js and phpfile encryption 2fdecryption using phpdecrypt encrypted file phphow to encrypt decrypt data in phpaes ciphertext decryption information in php with iv and salt lengthhash php decryptcript whit key phphow to securely encrypt and decrypt in phpaes encryption and decryption in php php password encryptionjavascript encryption decryption to phphow to encrypt and decrypt a php string 3fencrypt and decrypt function in php with a keyphp simple encrypt and decryptphp decrypt aes 128 cbcencrypt and decrypt file php libraryphp encrypt encrypthow to decrypt encrypted php codephp encrypt decrypt integerpassword encryp phpphp strong encryptions for stringsopenssl decrypt phpencrypt phpdecrypt phpencryption password in phpcreate encryption library for phphow encrypt text in android and decrypt in phppassword encryption in phpencrypt in php and decrypt in pythonphp encrypt stringaes php encryptionpassword decrypt phpphp basic encryption decryption functionencrypt in c 23 and decrypt in phpphp encrypt message crypt 28 29 decryptcore php password encryption and decryptionmake an encryption and decryption in phphow to encrypt and decrypt password in phpencryption and decryption password in phphow to incrypt decrypt in phpmake encrypted of length 32 phpencrypt and decrypt in 8 char id in phphow to decrypt password when i encrypt password with sha1 5din phpphp encrypt string and retrieve by decrypthow to do encryotion and decryption in phpvideo file encrypt decrypt phpsimple encrypt and decrypt in phpphp password decryptionsimple encryption and decryption in phpencryption and decryption of password in phpget cipher method from decrepted text in phpbest encrypt decrypt phppassword encryption and decryption in phpphp encrypt decrypt vs rcewhen i decrypt php it gives me something elsephp file decryptrijndael 256 cbc 7 paddingencrypt in php and decrypt in c 23how to encrypt small php codeencrypt decrypt id in phpphp simple password encrypt decryptdecrypt and encypt in phpphp hash encrypt decryptsecure way of encrypt 2fdecrypt password in phpandroid php encrypt decryptphp decrypt aeshow to encryot decrypt php with keyphp encryptionphp encryption decryptionhow to encrypt password phpencrypt in php and decrypt in phphash encryption and decryption in phphow to encrypt string and decrypt string in phpencrypt in javascript and decrypt in phpsalt based encrypt and decrypt using phpohow to encrypt and decrypt string in phpdecrypt crypt 28 29 in phpaes c 2b 2b to phpcrypt and decrypt php 5 6php encrypt aes and java decryptphp code for aes encryption and decryptionphp how to encrypt and decrypt dataencryption and decryption of data in phpencryption decryption in phpphp crypt decrypthash encrypt decrypt phpphp encrypt decrypt stringphp ecrypt and decrypt passwordsphp crypt to stringdecrypt php functionencryption library phphow to encrypt and decrypt password in php using hashhow to make encrypt decrypt login in phpphp encrypt decrypt hashphp openssl encrypt decrypt examplehow does php deal with incorect cipher keyssecure password encryption in php read and decryptsah1 decrypt in phpphp encrypt decrypt examplephp encrypt decrypt dataciphertext in function doesn 27t work but out of function does phpphp encrypt to stringphp encrypt and decrypt passwordfunction encrypt decrypt phptools to perform aes 256 encryption phpphp simple encryption decryptionwhat password encryption does laravel usephp string encryption and decryption 3fencrypt and decrypt string phpcrypt and decrypt url to 32 characters phpfile encryption and decryption project in phpphp encrypt decrypt passwordencrypt decrypt php javascriptencryption and decryption in php examplephp in password to encriptdecrypt password in phparray encryption and decryption in phpphp script to encrypt an inputencrpt decrypt phpencryption password phphow to decrypt an encrypted code phphow to see a string of encripted password phpaes encryption and decryption in php examplewhat is the best way to encrypt and decrypt password in phpmaintain end to end encryption phphow to encrypt and decrypt string in phpencrypt and decrypt function in phphow to encrypt and decrypt password in php mysqlencrypt decrypt phpphp key encryption and decryptiondecrypt php passwordpass decryptor in phpencryption functions in phpencrypt decrypt php 7how to re encrypt phphpw decrypt encrypted password in phpencrypt value in phpphp password encryptionreplace php encrypt decryptphp password encrypt and decryptphp openssl encrypt and decrypt examplehow to encrypt a password in phppassword value check geeks for geeks phpphp text encriptionencrypted to plain text in not working phpopenssl encrypt and decrypt string phpencrypt and decrypt user password in phpdecrypt php codeencrypt 2fdecrypt data phpphp encrypt a stringencryption 26 decryption phpencrypt and decrypt php 7php hash encrypt and decrypt phpbcrypt encrypt and decrypt php encrypt string php 24ciphertext 3d base64 encode 28 24ciphertext 29 3b add salted hash with this in phpdecrypt encrypt phpopenssl encrypt phpphp encrypt and decrypt functionsencryption and decryption project in phpphp mcrypt decryptphp deccyript passwordencryption and decryption php projectcustom password encrypt and decrypt phpphp decrypt string encrypted in codeinger 4encryption and decryption algorithm in phpphp encry with aesdecrypt crypt password phpencrypt decryt phpencrypt and decrypt number in phpcrypt decrypt string phpdecrypt password phpvideo encryption and decryption in phpencrypt and decrypt password in phphow to do encrypt and decrypt in phpencrpt and decrypt text in phpphp encrypt message encrypt 28 29 decryptencryption and decryption in php mysqlphp encrypt decrypt onlineopenssl encrypt and decrypt phpencrypt in jquery and decrypt in phpphp encrypt and decrypt datahow to encrypt decrypt string phpphp encrypt decrypt idencrypy messages phpfunction to encrypt or decrypt a stringphp mcrypt encrypt php 7php how to decrypt passwordphp password encryptdecrypt php password hashphp in encript by text not workingphp decrypt and encrypt stringcrypto encrypt and decrypt in phpphp encrypt decrypt for urlencrypt decrypt password php mysqlphp encrypt decrypt tutorialhow to decrypt phprijndael encryption php 128 by 16php password hash decryptphp encrypt decrypt with keyphp mysql encrypt decrypt dataphp incrypt and decrip 5bt a stinghow to encrypt decrypt in phpstr encrypt phpphp password decryptopenssl encrypt decrypt phpencrypting and decrypting php encrypt text like phpphp response encrypted payload how to decryptphp encrypt and decrypt stringcustom encryption and decryption in phpcan i decrypt encrypted php source code without passwordhow to decrypt in phpencrypt decrypt text phphow to encrypt and decrypt a password in phpencrypted decrypt in phphow to encrypt data php and automatically decrypts themencrypt and decrypt phpencripted to text in phpphp aesmake own aes phpciphertext in fucntion doesnt work but out fo fucmtion does phpphp mcrypt decrypt examplephp encrypt and decrypt back to textmessage encrypt and decrypt in phpencrypting and decrypting data in phpdecrypting password in phphow to make encryption in php string and decryptphp aes methodhow to decrypt password hash phpphp encrypt decrypt lengthphp code encrypt to decrypt onlinehow to encrypt and decrypt password in php using sha1encryption and decryption in phpmake custom encrypt decrypt in phppassword hash decrypt phphow to decrypt a string in php encryptionphp encrypt and decrypt an objectpassword encrypt phpaes encryption phpphp encrypt and decrypt with keyphp encrypt decryptphp decrypt string with keyphp ecrypt and decryptdcrypt and encrypt in phpphp encrypt decrypthow encrypt and decrypt password in phpencrypt decrypt php online5 php decryptphp encrypt url and decrypt string with keyfunction encrypt decrypt password phpencrypting passwords in phpjs encrypt php decryptencryption and decryption in php class phpphp aes encryptionhow to decrypt password hash in phpphp encrypt and decrypt functionphp encrypt and decryptdecrypt php password databasephp simple encrypt and decrypt algorithmphp encrypt decrypt textencrypt decrypt function in phpphp simple 10 encrypt and decrypt 27 2f 27 is encrypted 2 times in php aes php scriptphp encrypt decrypt string simplephp encryptingaes 256 php save encryption key as textpassword encryption phpencrypt data phphow to encrypt and decrypt integer in phpaes php codephp function to encrypt and decryptaes algorithm in phpcara encrypt decrypt phpcore php sql password encryption and decryptionmcrypt encrypt php 7php encrypt and decrypt textmcrypt decrypt phpbest function to decrypt password in phpaes phpcrypt and decrypt phpdecrypt phpbb passwordcrypt php decryptpassword encrypt and decrypt in phpencrypt and decrypt a string in phpdecode php has password into stringpassword encrypt decrypt phpphp encryption passwordencrypt in phphow to use aes encryption in phpphp encryptaes 256 encryption and decryption in phpencrypt decrypt php classencrypt in php and decrypt in jsencrypt and decrypt password in core phpdecrypt crypt function in phpandroid encrypt decrypt in php encrypted datasimple encrypt decrypt phpsimple string encrypt decrupt phphow to encrypt the password in phpencrypting and decrypting in phpphp encrypt 2fdecryptencrypt password phpencrypt and decrypt in phpaes encrypt decrypt in php with saltencrypt text phpaes decryption in phpphp decryptphp encrypt decrypt with salthow to decrypt password in phpall aes method in phpdecript password in php using encryptcrypt 3a 3adecrypt phpword encrypter and decrypter phpaes encryption in phpphp string encryption and decryptionhow to encrypt and decrypt message in phppublic key encryption and decryption in phphow to encrypt and decrypt a string in phpphp encrypt and decrypt arrayencrypt password in windows form 2c decrypt in phpphp aes decriptencrypt phpencrypt in js and decrypt in phpphp password encryption and decryptiondecrypt php function simpledecrypt in phpencrypt and decrypt password in php mysqlencrypt and decrypt file phpsimple php encrypt decryptbcrypt encryption phpreversible encryption phpencrypt file in folder php and decryptphp encrypterfunction of password encryption in phpget algorithm for encryption and decryption in phpphp text encrypt decryptjsencrypt php decryptpassword encryption and decription in phpencrypt decrypt password in phphow to make a php encryption and decryption codephp encryption and decryption codehow to encrypt and decrypt id in phpencryption in phpencryptit php 2f 2fdecrypt function function decryptthis 28 24data 29 7b phpencrypt with java and decrypt with phpphp 2 way encryption with saltseveral methods to encrypt and decrypt a value for phphow to encrypt and decrypt password in php using sha256php can encrypt data what that meansphp mysql password encryption decryptionphp encryptedhow to decrypt php hashhow to encrypt password using phppassword encrypt in phpphp best password encryption and decryptionphp password decrypterencrypt and decrypt text messages in pure php codehow to encrypt and decrypt string in php between 2 filesencrypt and decrypt password phpdecrypt function in phphash password decrypt in phpencryption in javascript and decryption in phpaes in phpfile encryption and decryption phpdecrypt password com encrypt phpssl encryption php examplehow to encrypt and decrypt in phphow to encrypt password and then decrypt password in phphow to decrypt crypt password in phphow to encrypt in phphow to hash and unhash a string in phpphp encrypt passwordphp two way encrypt decrypthow to encrypt and decrypt password phpcrypt encrypt phpdecrypt with phpphp password hash decrypt onlinephp encrypt dataencrypt decrypt phpencrypt decrypt password phpphp encrypt decrypt filesaes algorithm phpphp pass encryptionphp encrypt texthow to decrypt a password in phpdecrypt 28 29 php2way fixed encryption phpsimple encrypt decrypt hash protect phpphp decrypt passwordphp encrypt stringphp encrypt and decrypt with public keyjavascript encrypt php decryptencrypt decrypt in phpphp openssl encrypt decrypt stringcore php password encryption and decryption codeencrypt decrypt php