tailieunhanh - Beginning PHP and MySQL E-Commerce From Novice to Professional phần 8

Xóa giỏ hàng mua sắm shopping_cart_empty CALL (inCartId) - Quay trở lại ID đặt hàng CHỌN OrderID; END $ $ 9. Sửa đổi thủ tục lưu trữ orders_get_order_info bằng cách xóa phiên bản cũ và tạo ra một cái mới (đừng quên để thiết lập dấu phân cách $ $): - | Simpo PDF Merge and Split Unregistered Version - http CHAPTER 16 MANAGING CUSTOMER DETAILS 489 Pack SymmetricCrypt _msHexaIv into a binary string binary_iv pack H self _msHexaIv The conversion is done using PHP s pack function learn more about it at http pack . The call to mcrypt_encrypt follows Encrypt plainString binary_encrypted_string mcrypt_encrypt self _msCipherAlgorithm self _msSecretKey plainString mCrypt_mode_cbc binary_iv This is the call that performs the actual encryption. Its parameters are obvious and you can find more detail about the mcrypt_encrypt function at http MCRYPT_MODE_CBC specifies the cipher block chaining encryption method this method uses a chaining mechanism in which the encryption of each block of data depends on the encryption results of preceding blocks except for the first block in which the IV is used instead. At the end the encrypted string is transformed into hexadecimal format which is easier to work with for example to save in the database or in a configuration file Convert binary_encrypted_string to hexadecimal format hexa_encrypted_string bin2hex binary_encrypted_string The Decrypt method is similar to the Encrypt method. First you need the IV to be in a binary form the same first step you took in the Encrypt method . As the Encrypt method returns the encrypted string as a hexadecimal string the input parameter of Decrypt is also a hexadecimal string. You must convert this string to a byte array which is the format that mcrypt_decrypt needs Convert string in hexadecimal to byte array binary_encrypted_string pack H encryptedString Decrypt binary_encrypted_string decrypted_string mcrypt_decrypt self _msCipherAlgorithm self _msSecretKey binary_encrypted_string MCRYPT_MODE_CBC binary_iv return decrypted_string The test file for this class simply encrypts and decrypts data demonstrating that things are working properly. The code for this is very simple so we .

TỪ KHÓA LIÊN QUAN