Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Library providing various hash algorithms (MD5, SHA1, SHA256, etc) in Java?

Is there a simple library out there for Java in a Maven repository that will give me simple, one-liner hash methods for the popular hash functions such as MD5, SHA1, SHA256, and SHA512? I'd really hate to have to reinvent the wheel to do this.

like image 300
Naftuli Kay Avatar asked Jun 02 '11 04:06

Naftuli Kay


People also ask

What is SHA256 in Java?

The SHA-256 algorithm generates an almost unique, fixed-size 256-bit (32-byte) hash. This is a one-way function, so the result cannot be decrypted back to the original value. Currently, SHA-2 hashing is widely used, as it is considered the most secure hashing algorithm in the cryptographic arena.

What is hashing algorithm in Java?

An algorithm that does the mapping of data to a hash of fixed size is called the hashing algorithm. Hashing algorithm in Java is a cryptographic hash function. A hash algorithm or hash function is designed in such a way that it behaves like a one-way function.

What is SHA-256 hashing algorithm?

SHA-256 stands for Secure Hash Algorithm 256-bit and it's used for cryptographic security. Cryptographic hash algorithms produce irreversible and unique hashes. The larger the number of possible hashes, the smaller the chance that two values will create the same hash.


1 Answers

The DigestUtils class of Apache Commons Codec is suitable for the purpose of simplifying the use of the MessageDigest class, which appears to be what you are attempting to use in the first place.

like image 83
Vineet Reynolds Avatar answered Oct 18 '22 10:10

Vineet Reynolds