import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class SHA256Util {
public static String SHA256Encrypt(String text) throws NoSuchAlgorithmException, UnsupportedEncodingException{
StringBuffer hexString = new StringBuffer();
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest(token.getBytes("UTF-8"));
for(int i=0; i < hash.length; i++){
String hex = Integer.toHexString(0xff & hash[i]);
if(hex.length() == 1) hexString.append('0');
hexString.append(hex);
}
return hexString.toString();
}
}
'Programming > JAVA' 카테고리의 다른 글
색상 거리 구하기(feat. CIEDE2000) (0) | 2023.05.30 |
---|---|
[pdfbox] PDF 파일을 Image파일로 변환하는 방법 (0) | 2023.05.10 |
[Apache VFS] SFTP 파일 업로드 (0) | 2023.03.08 |
[openhtmltopdf] HTML을 PDF로 변환하기 (0) | 2023.01.18 |
[Apache Tika] 문서파일에서 텍스트 추출하기 (0) | 2022.12.15 |