MAC DEC CBC
Recently there is a project that sends messages using the MAC (message authentication Code), using the DES CBC algorithm.
Online check, probably meaning is to give the data to calculate a check code, with the data itself sent out, the end of the verification code to confirm whether the data has been tampered with.
Want to ask, PHP has no function can directly implement this function, their own writing function is segmented, is different or, is also the encryption of the head is big. I think there is mcrypt_cbc such a function, do not know whether there is any relationship.
Please help the master! It would be better to give an example to illustrate, or to point to a direction.
Reply to discussion (solution)
Mcrypt_cbc
Use CBC to add/decrypt data.
Syntax: string MCRYPT_CBC (int cipher, string key, string data, int mode, string [IV]);
return value: String
Function type: Encoding processing
Content Description
This function uses CBC password retrieval (cipher block chaining) to encrypt and decrypt the data. The parameter cipher is an Add/decrypt method, such as Mcrypt_tripledes. Parameter key is the password key, of course, it should be careful to maintain its confidentiality. The string to encrypt or decrypt is placed in the parameter data. The parameter mode means encrypting the Mcrypt_encrypt or decrypting the mcrypt_decrypt. The parameter IV is an omitted parameter that represents the vector initialization (initialization vector, IV).
Forgive me for copying the official instructions, but purely from the interpretation, this is a cryptographic function. According to your needs, although you can generate a ciphertext, and then the key also sent over, to the end of the sent over the plaintext with the same key again encrypted, compared ciphertext, it is possible to achieve the purpose of verification. However, the key transmission loses its security. Relatively simple, MD5 seems to be much easier. Because no key is required.