![JAR search and dependency download from the Maven repository](/logo.png)
common.crypto.SHA256 Maven / Gradle / Ivy
package com.unbound.common.crypto;
import com.unbound.common.STR;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
public final class SHA256
{
private MessageDigest md;
public SHA256()
{
md = SystemProvider.MessageDigest.getInstance("SHA-256");
}
public SHA256 update(byte[] in)
{
md.update(in);
return this;
}
public SHA256 update(byte[] in, int offset, int length)
{
md.update(in, offset, length);
return this;
}
public SHA256 update(String in)
{
md.update(STR.utf8(in));
return this;
}
public byte[] end()
{
return md.digest();
}
public static byte[] hash(byte[] in)
{
return new SHA256().update(in).end();
}
public static byte[] hash(String in)
{
return new SHA256().update(in).end();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy