Example of simple AES encryption and decryption algorithm implemented by PHP and example of aes encryption and decryption algorithm
This example describes the simple AES encryption and decryption algorithm in PHP. We will share this with you for your reference. The details are as follows:
/** Implement AES encryption * $ str: string to be encrypted * $ keys: encryption key * $ iv: encryption vector * $ cipher_alg: encryption mode */function ecryptdString ($ str, $ keys = "6461772803150152", $ iv = "8105547186756005", $ cipher_alg = encrypt) {$ encrypted_string = bin2hex (mcrypt_encrypt ($ cipher_alg, $ keys, $ str, MCRYPT_MODE_CBC, $ iv); return $ encrypted_string;}/** implement AES decryption * $ str: string to be decrypted * $ keys: encryption key * $ iv: encryption vector * $ cipher_alg: encryption Method */function decryptStrin ($ str, $ keys = "6461772803150152", $ iv = "8105547186756005", $ cipher_alg = encrypted) {$ decrypted_string = mcrypt_decrypt ($ cipher_alg, $ keys, pack ("H *", $ str), MCRYPT_MODE_CBC, $ iv); return $ decrypted_string ;}
PS: if you are interested in encryption and decryption, refer to the online tools on this site:
Online text encryption and decryption tools (including AES, DES, and RC4 ):
Http://tools.jb51.net/password/txt_encode
MD5 online encryption tool:
Http://tools.jb51.net/password/CreateMD5Password
Online hash/hash algorithm encryption tool:
Http://tools.jb51.net/password/hash_encrypt
Online MD5/hash/SHA-1/SHA-2/SHA-256/SHA-512/SHA-3/RIPEMD-160 encryption tools:
Http://tools.jb51.net/password/hash_md5_sha
Online sha1/shaloud/sha256/sha384/sha512 encryption tool:
Http://tools.jb51.net/password/sha_encode