encryption and decryption in php example

Solutions on MaxInterview for encryption and decryption in php example by the best coders in the world

showing results for - "encryption and decryption in php example"
Hyacinth
30 Oct 2016
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
Jannik
30 Nov 2019
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}
Sofia
27 Jan 2018
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?>
Sara Sofía
04 Aug 2019
1$decoded = base64_decode($encoded);
2
queries leading to this page
encrypt decrypt phpphp crypt encrypt decryptphp encrypt unencrypt with keyhow to encrypt string and decrypt string in phpwhat other methods can i use to encrypt and decrypt a string using phpencrypt and decrypt password in core phphash encrypt decrypt phpdecrypt with phphow to decrypt an encrypted code phpphp encrypt decrypt stringaes encryption and decryption in phphow to decrypt php hashjava encrypt decrypt in phpencrypt a string using decrypt key in phpdcrypt and encrypt in phpphp can encrypt data what that meanshow to encrypt and decrypt password in php using hashhow to encrypt password in phpphp crypt decryptencryption and decryption project in phpencrypt and decrypt text messages in pure php codehow to decrypt crypt password in phpencrypt and decrypt a string in phpphp encrypt aes and java decryptphp encrypt and decrypt arrayohow to encrypt and decrypt string in phpphp in password to encripthow to decrypt password in phpfile encryption 2fdecryption using phpphp mcrypt encrypt php 7php response encrypted payload how to decryptencrypt decrypt id in phprijndael 256 cbc 7 paddingencrypt en decrypt phpphp decrypt and encrypt stringphp how to encrypt text with a saltget cipher method from decrepted text in phpphp encrypt decrypt tutorialphp encrypt decrypt string simplehow to encrypt and decrypt in phppassword hash decrypt phpdatabase encrypted password decrypted to match in phpphp deccyript passwordphp encrypt encryptphp encrypterphp password hash decryptencrypt with java and decrypt with phpaes decryption in phpaes 256 encryption and decryption in phpdecrypt php password databasemessage encrypt and decrypt in phpphp in encript by text not workingencrypt phpencrypting and decrypting in phphow to encrypt in phppassword decryption in phphow to encrypt password phphow does php deal with incorect cipher keysphp decrypt string with keyphp encrypt a stringhow to encrypt and decrypt a password in phpphp decrypt aes 128 cbcencrypt in php and decrypt in phphash php decryptphp string encryption and decryptionencrypt and decrypt id in phpcrypt decrypt string phpphp encrypt to stringphp encrypt and decrypt texthow to encrypt and decrypt password in php using sha1encryption 26 decryption phpphp aes encrypt 2f decrypthow to encrypt and decrypt string in phpencrypt 2fdecrypt data phpphp encrypt 2fdecrypthow encrypt and decrypt password in phpword encrypter and decrypter phphash decrypt phpcrypto encrypt and decrypt in phpphp password encryptionhow to encrypt password using phpencrypt and decrypt password in php mysqlmake encrypted of length 32 phpcreate encryption library for phpencrypt and decrypt string in phphow to encrypt decrypt string phphow to decrypt in phpdecrypt php codeencrypt in phpphp simple encrypt and decryptencrypt text like phphow to incrypt decrypt in phpencryption and decryption of password in phpencrypt and decrypt function in phpphp how to decrypt passwordencrypt decrypt password in phpphp encrypt textdecrypt to encrypt php onlinebest encrypt decrypt phpphp encrypt decryptaes 256 php save encryption key as textphp encryptionphp encrypt decrypt passwordjsencrypt php decryptphp simple 10 encrypt and decrypthow to encrypt decrypt data in phpcan i decrypt encrypted php source code without passwordencrypt in php and decrypt in jsfunction encrypt decrypt password phpphp text encriptionphp openssl encrypt decrypt stringphp encryptingphp encrypt message crypt 28 29 decryptphp mysql password encryption decryptionencryption in phpphp script to encrypt an inputencryption and decryption of data in phpencrypt decrypt php classmake an encryption and decryption in phpcrypt php decryptphp encrypt decrypt dataencrypt and decrypt file phpwhat password encryption does laravel useencryption password phpphp function to encrypt and decryptcrypt and decrypt php 5 6encrpt decrypt phphow to encrypt password and then decrypt password in phphow to encrypt and decrypt integer in phphow to encrypt data php and automatically decrypts themhow to decrypt password when i encrypt password with sha1 5din phpreversible encryption phpphp unsafe encryptionpass decryptor in phpencryption and decryption phpphp encrypt decrypt hashencrypting and decrypting php openssl encrypt phparray encryption and decryption in phpjavascript encryption decryption to phpciphertext in fucntion doesnt work but out fo fucmtion does phpencryptit phpdecrypt php functionbcrypt encryption phpopenssl encrypt and decrypt phptools to perform aes 256 encryption php2way fixed encryption phpencripted to text in phpciphertext in function doesn 27t work but out of function does phpphp encrypt decrypt textopenssl encrypt decrypt phpdecrypt crypt password phpsah1 decrypt in phpphp crypt to stringdecrypt in phpphp code encrypt to decrypt onlinehow to encrypt and decrypt id in phpphp password decryptfast random encryption in phphow to encrypt the password in phpphp password decryptiondecrypt crypt 28 29 password in written in phpencrypt decrypt php onlinedecript password in php using encrypthow to re encrypt phpfunction encrypt decrypt phpphp encrypt and decrypt back to textaes encryption and decryption in php exampleencrypt and decrypt file php libraryphp encrypt decrypt vs rcefile encryption and decryption project in phppassword encryption phppassword encrypt decrypt phpsimple encrypt decrypt phpphp simple encrypt decryptphp openssl encrypt and decrypt exampledecrypt encrypted file phpphp how to encrypt and decrypt dataencrypt decrypt function in phpandroid encrypt decrypt in php encrypted data 2f 2fdecrypt function function decryptthis 28 24data 29 7b phpcrypt 3a 3adecrypt phphow to decrypt a password in phpandroid php encrypt decrypthash encryption and decryption in phphow to securely encrypt and decrypt in phpphp encrypt decrypt files 24ciphertext 3d base64 encode 28 24ciphertext 29 3b add salted hash with this in phpcore php password encryption and decryption codeencrypt in js and decrypt in phpcrypt encrypt phpphp pass encryptiondecrypt password com encrypt phpdecrypt crypt function in phpcara encrypt decrypt phpencrypt in php and decrypt in c 23easy php encryption decryptiondecrypt crypt function phpfunction of password encryption in phpencrypt with key phpencryption and decryption php projectphp key encryption and decryptionphp password hash decrypt onlinedecrypt data phpphp encrypt decrypt functionencrypt in jquery and decrypt in phpencrypt password in windows form 2c decrypt in phpphp hash password decryptsimple encrypt decrypt hash protect phpdecrypt password in phpencrypt decrypt string in phphow to encrypt and decrypt password in php mysqlencryption and decryption in phpsalt based encrypt and decrypt using phpphp ecrypt and decryptphp 2 way encryption with saltvideo encryption and decryption in phpencryption and decryption in php examplemcrypt encrypt php 7encryption password in phpdecrypt and encypt in phpencryption in javascript and decryption in phpencrypt and decrypt php 7how to encrypt and decrypt password in php using sha256php encrypt decrypt integerphp encrypt and decrypt functionencrypt and decrypt user password in phpphp hash encrypt and decrypt phprijndael encryption php 128 by 16decrypt php function simplehow to decrypt password hash in phpcore php password encryption and decryptiondecode php has password into stringencrypt in c 23 and decrypt in phphow to encrypt a password in phpphp encrypt and decrypt passworddecrypt encrypt phpdecrypt php passwordhow to encrypt and decrypt message in phpencryption and decryption in php class phpencrypt decrypt php javascriptencrypt and decrypt function in php with a keyencrypted to plain text in not working phpencrypt decryt phpopenssl encrypt and decrypt string phpencrypt value in phphow to decrypt encrypted php codesimple php encrypt decryptpassword encryp phpphp rijndael encrypt 2fdecryptcustom password encrypt and decrypt phppassword value check geeks for geeks phpphp encode with keycustom encryption and decryption in phpphp encrypt message encrypt 28 29 decrypt 27 2f 27 is encrypted 2 times in php encrypt decrypt php 7encrypt and decrypt data in php decrypt password phpphp encrypt decryptbest function to decrypt password in phphow to see a string of encripted password phpphp encrypt decrypt for urlphp decrypt aeswhen i decrypt php it gives me something elseencrypted decrypt in phphow to decrypt php php password encryptionencrypt decrypt password phpjs encrypt php decrypthow to encrypt small php codemcrypt decrypt phphow to hash and unhash a string in phpphp encrypt and decrypt functionshow to encrypt decrypt in phpsimple encrypt and decrypt in phpphp encrypt5 php decryptphp encrypt decrypt with salthow to make encrypt decrypt login in phphow to encrypt and decrypt string in php between 2 fileshow to decrypt a string in php encryptionphp password decrypterencrypt decrypt file phpencrypt and decrypt phpencryption php passwordmake custom encrypt decrypt in phpencrypt decrypt text phpfunction to encrypt or decrypt a stringphp text encrypt decryptadd encryption to text in phpphp encrypt decrypt idreplace php encrypt decryptdecrypt phpbb passwordencrypt and decrypt number in phpcript whit key phppassword encrypt in phpencrypt string in phpsecure way of encrypt 2fdecrypt password in phpstr encrypt phpencrypt phpcore php sql password encryption and decryptionencryption phpjavascript encrypt php decryptphp encrypt and decrypt with public keyopenssl decrypt phpphp decrypt string encrypted in codeinger 4php encrypt string and retrieve by decrypthow to encrypt and decrypt password phpphp encrypt and decrypt datahow to do encrypt and decrypt in phpphp encrypt stringhow to encrypt and decrypt a string in phpencrypting passwords in phpphp basic encryption decryption functionphp simple encrypt and decrypt algorithmdecrypt function in phpphp best password encryption and decryptionsimple encryption and decryption in phpbcrypt encrypt and decrypt php encrypting and decrypting data in phpdecrypt php password hashphp mcrypt decrypt examplephp code for aes encryption and decryptionhow to make encryption in php string and decryptphp best encryption and decryptionencryption library phpencrypt text phpencrypt decrypt phpphp encrypt decrypt intdecode and encode messages decrypt and encrypt phpphp strong encryptions for stringsencrypt and decrypt password phppgp encryption and decryption phpphp encryption passwordfile encryption and decryption phphow to decrypt password hash phpphp encrypt decrypt with keyphp incrypt and decrip 5bt a stinghow to decrypt php passwordpassword encrypt phpphp decryptget algorithm for encryption and decryption in phphash password decrypt in phpaes ciphertext decryption information in php with iv and salt lengthencrypt in javascript and decrypt in phpencrypt decrypt password php mysqlpassword encryption in phpphp crypt function decryptencryption and decryption algorithm in phpencrypt file in folder php and decryptphp two way encrypt decryptdecrypt password php mysqlphp decrypt passwordphp mysql encrypt decrypt datapassword encrypt and decrypt in phpphp encryptedencryption and decryption in php mysqlhow to encrypt and decrypt password in phphow to do encryotion and decryption in phpencrypt and decrypt in phpphp simple encryption decryptioncrypt and decrypt phpdecrypt phpaes encrypt decrypt in php with saltphp easily encrypt and decrypt dataencrypt and decrypt using phpphp password encryption and decryptionphp encrypt and decryptseveral methods to encrypt and decrypt a value for phpencryption functions in phpencrypt and decrypt string phpphp string encryption and decryption 3fencrypt decrypt in phpencrypy messages phpphp encryption and decryption codeencrypt and decrypt password in phpsimple string encrypt decrupt phpdecrypt crypt 28 29 in phpencryption decryption in phppassword decrypt phpencrpt and decrypt text in phpwhat is the best way to encrypt and decrypt password in phpphp encrypt and decrypt stringphp simple password encrypt decryptencrypt string phphow to encrypt and decrypt a php string 3fphp encrypt decrypt lengthpassword encryption and decription in phpphp encrypt and decrypt with keyaes encryption phpphp ecrypt and decrypt passwordsphp mcrypt decryptpassword encryption and decryption in phphow to make text encrypt and decrypt phpsecure password encryption in php read and decryptdecrypt 28 29 phphow to encryot decrypt php with keydecrypting password in phpphp password encryptphp password encrypt and decryptphp encrypt passwordpublic key encryption and decryption in phphpw decrypt encrypted password in phpencrypt password phpmaintain end to end encryption phpphp encrypt and decrypt an objectphp code to encrypt and decrypt passwordphp encrypt decrypt examplecrypt and decrypt url to 32 characters phpphp encrypt decrypt onlinephp encryption decryptionhow to make a php encryption and decryption codeencryption and decryption password in phpphp openssl encrypt decrypt examplephp hash encrypt decryptssl encryption php examplephp file decryptencryption and decryption in php example