DESCBC message verification method for php MAC DEC CBC
Recently, a project uses the Message Authentication Code (MAC) and the des cbc algorithm to send information.
I checked it online, which probably means to calculate a verification code for the data and send it together with the data itself. the peer checks whether the data has been tampered with based on the verification code.
I would like to ask if there are any functions in PHP that can directly implement this function. if you write your own functions, they are segmented, different, or encrypted. I don't know if there is a function like mcrypt_cbc.
Please help! It is better to give an example or a direction.
Reply to discussion (solution)
Mcrypt_cbc
Use CBC to encrypt/decrypt data.
Syntax: string mcrypt_cbc (int cipher, string key, string data, int mode, string [iv]);
Return value: string
Function type: encoding
Description
This function uses the CBC password to retrieve the chaining (cipher block chaining) and encrypt and decrypt the data. The cipher parameter is the encryption/decryption method, for example, MCRYPT_TripleDES. The parameter key is the password key. of course, you must maintain its confidentiality. Strings to be encrypted or decrypted are placed in the parameter data. The mode parameter indicates MCRYPT_ENCRYPT encryption or MCRYPT_DECRYPT decryption. The parameter iv is an ignored parameter, indicating vector Initialization (Initialization vector, IV ).
Forgive me for copying the official description, but simply from the explanation, this is an encryption function. According to your needs, although you can generate a ciphertext, and then send the KEY together, the peer end encrypts the plaintext sent with the same KEY and compares the ciphertext, is to achieve the purpose of verification. However, KEY transmission loses security. Relatively simple, MD5 seems easier. Because no key is required.