Message Digest --- MD5 encryption, digest --- md5 Encryption

Source: Internet
Author: User
Tags md5 digest

Message Digest --- MD5 encryption, digest --- md5 Encryption
Password Encryption

Generally, the "Message Digest" technology is used to encrypt the password to avoid saving the password in "plaintext.

Plaintext: Original Text

Message Abstract

Is a common data integrity testing technology.
The message digest is equivalent to the fingerprint of data information (files, strings ).

 

Import api: commons-codec

<! -- Apache provides common encoding packages: Message Digest, encryption, decryption, Bese64 encoding, HEX Encoding, and so on -->
<Dependency>
<GroupId> commons-codec </groupId>
<ArtifactId> commons-codec </artifactId>
<Version> 1.10 </version>
</Dependency>

 

The following is the test code:

/*** Calculate the Digest (MD5) of a file * md5sum passwd */@ Test public void testFileDidest () throws Exception {// The file passwd is saved in the project folder String file = "passwd"; // open the file InputStream in = new FileInputStream (file ); // calculate the MD5 Digest of data in the file String md5 = DigestUtils. md5Hex (in); System. out. println (md5 );}

Output: 7119a2ae9f636c6ffb9029fd71fadf8

 

The following describes how to obtain salt using Spring Annotations:

Add salt to the database configuration file (db. properties) to improve the security. You can add salt verification to registration and logon.

salt=\u4ECA\u5929\u4F60\u5403\u4E86\u5417\uFF1F

Database Connection Pool configured in the Spring-dao.xml File

<! -- Load the configuration file of the database connection pool --> <util: properties id = "dbConfig" location = "classpath: db. properties"/>

In this way, the salt can be obtained.

@Value("#{dbConfig.salt}")private String salt;

 

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.