C ++ MD5 operations (including source code download)

Source: Internet
Author: User

Although some C ++ third libraries have inherited the MD5 operation, sometimes we need a lightweight MD5 library function. Here we provide an MD5 class that can pass in a string to generate the MD5 result.

MD5 library download

After downloading and unzipping, there are three files: md5.h md5.cpp main. cpp, where md5.h and md5.cpp are MD5 Class header files and implementation files, and Main. cpp is a test file.

Compile and run

 
G ++ md5.cpp main. cpp-O main
./Main

Output result:

 
ABC MD5Is900150983cd24fb0d6963f7d28e17f72

The content of the Main. cpp file is also an example of MD5 class usage, as follows:

# Include"Md5.h"
# Include <String>
# Include <iostream>
IntMain (){
Using NamespaceSTD;
StringSTR ="ABC";
MD5 MD5 (STR );
StringResult = md5.md5 ();
Cout <"ABC MD5 is"<Result <Endl;
Return 0;
}

Test reference http://www.cmd5.com/

 

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.