All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.litongjava.tio.utils.encoder.Sha1Utils Maven / Gradle / Ivy

There is a newer version: 3.7.3.v202400213-RELEASE
Show newest version
package com.litongjava.tio.utils.encoder;

import java.nio.charset.Charset;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Sha1Utils {
	
	private final static String ALGORITHM = "SHA-1";
	
	public static byte[] SHA1(byte[] decript) {
		try {
			MessageDigest digest = java.security.MessageDigest.getInstance(ALGORITHM);
			digest.update(decript);
			return digest.digest();
		} catch (NoSuchAlgorithmException e) {
			throw new RuntimeException(e);
		}
	}
	
	public static byte[] SHA1(String decript) {
		return SHA1(decript.getBytes());
	}

	public static String SHA1(String decript, Charset encoding) {
		byte[] array = SHA1(decript);
		return new String(array, encoding);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy