DESCBC message verification method in php

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.