public class HashUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
SHA_256 |
Constructor and Description |
---|
HashUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
generateSecureRandomString(int length)
Generates a random string that can be used for passwords or tokens
https://stackoverflow.com/a/31260788/1278769
|
static long |
getChecksum(java.io.File file)
Uses Adler32 to calculate a checksum of a file
|
static java.lang.String |
getChecksum(java.lang.String str)
Uses MD5 to generate a 6 chars long checksum of a string
|
static java.lang.String |
getHash(java.nio.file.Path file,
java.lang.String hashFunction)
Calculates hash for the given file.
|
static java.lang.String |
getHash(java.lang.String str,
java.lang.String hashFunction)
Calculates hash with the given hash function.
|
static java.lang.String |
getHashMD5(java.lang.String str) |
public static final java.lang.String SHA_256
public static java.lang.String getHashMD5(java.lang.String str)
public static java.lang.String getHash(java.lang.String str, java.lang.String hashFunction)
public static java.lang.String getHash(java.nio.file.Path file, java.lang.String hashFunction) throws java.io.IOException
java.io.IOException
public static java.lang.String generateSecureRandomString(int length)
public static java.lang.String getChecksum(java.lang.String str)
public static long getChecksum(java.io.File file) throws java.io.IOException
java.io.IOException