Java Password Hashing with Argon2

Argon2 was the winner of the Password Hashing Competition in July 2015, a one-way hashing function that is intentionally resource (CPU, memory, etc) intensive. In Argon2, we can configure the length of the salt, the length of the generated hash, iterations, memory cost, and CPU cost to control the resources that are needed to hash …

Read more

Python MD5 Hashing Example

The MD5, defined in RFC 1321, is a hash algorithm to turn inputs into a fixed 128-bit (16 bytes) length of the hash value. Note MD5 is not collision-resistant – Two different inputs may producing the same hash value. Read this MD5 vulnerabilities. In Python, we can use hashlib.md5() to generate a MD5 hash value …

Read more

Maven – How to create a multi module project

In this tutorial, we will show you how to use Maven to manage a Multi-module project containing four modules : Password module – Interface only. Password md5 module – Password module implementation, MD5 password hashing. Password sha module – Password module implementation, SHA password hashing. Web module – A simple MVC web app to hash …

Read more

Java – List of available MessageDigest Algorithms

In Java, you can use the Security.getAlgorithms(“MessageDigest”) to list all the available MessageDigest algorithms. ListMessageDigest.java package com.mkyong.hashing; import java.security.Security; import java.util.Set; public class ListMessageDigest { public static void main(String[] args) { Set<String> messageDigest = Security.getAlgorithms("MessageDigest"); messageDigest.forEach(x -> System.out.println(x)); } } Output SHA3-512 SHA-384 SHA SHA3-384 SHA-224 SHA-512/256 SHA-256 MD2 SHA-512/224 SHA3-256 SHA-512 MD5 SHA3-224 P.S …

Read more

Spring Security : Encoded password does not look like BCrypt

In Spring Security, database authentication with bcrypt password hashing. import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder; //… String password = “123456”; PasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); String hashedPassword = passwordEncoder.encode(password); spring-security.xml <authentication-manager> <authentication-provider> <password-encoder hash="bcrypt" /> //… </authentication-provider> </authentication-manager> CREATE TABLE users ( username VARCHAR(45) NOT NULL , password VARCHAR(45) NOT NULL , enabled TINYINT NOT NULL DEFAULT …

Read more

Spring Security password hashing example

In this tutorial, we will show you how to use BCryptPasswordEncoder to hash a password and perform a login authentication in Spring Security. In the old days, normally, we used MD5 Md5PasswordEncoder or SHA ShaPasswordEncoder hashing algorithm to encode a password… you are still allowed to use whatever encoder you like, but Spring recommends to …

Read more

Java SHA-256 and SHA3-256 Hashing Example

In Java, we can use MessageDigest to get a SHA-256 or SHA3-256 hashing algorithm to hash a string. MessageDigest md = MessageDigest.getInstance("SHA3-256"); byte[] result = md.digest(input); This article shows how to use Java SHA-256 and SHA3-256 algorithms to generate a hash value from a given string and checksum from a file. Note The hashing is …

Read more

Java MD5 Hashing Example

The MD5, defined in RFC 1321, is a hash algorithm to turn inputs into a fixed 128-bit (16 bytes) length of the hash value. Note MD5 is not collision-resistant – Two different inputs may producing the same hash value. Read this MD5 vulnerabilities. There are many fast and secure hashing algorithms like SHA3-256 or BLAKE2; …

Read more

Java – Create file checksum with SHA and MD5

In this article, we will show you how to use a SHA-256 and MD5 algorithm to generate a checksum for a file. MessageDigest.getInstance(“algorithm”) Apache Commons Codec 1. MessageDigest d:\server.log hello world 1.1 Generate a file checksum with a SHA256 algorithm. FileCheckSumSHA.java package com.mkyong.hashing; import java.io.FileInputStream; import java.io.IOException; import java.security.DigestInputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class …

Read more