mirror of
https://github.com/Geprivilegieerde-Anonimiteit-BV/XACrypto.git
synced 2026-08-21 13:36:21 -04:00
read desc for info
SHA256.java is the MessageDigest usage, it sucks, don't use it. SHA256Advanced.java is my custom interpretation but i don't have the time right now to finish it so for now it will sadly be a placeholder.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package de.caydenno1.xacrypto.hash;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class SHA256 {
|
||||
// THIS IS A TEMPORARY FILE AND EXTREMELY VOLATILE!! it will be removed when i create a more advanced sha256 (i just dont have the time rn so this will be here for now)
|
||||
// this just uses MessageDigest and is extremely BAD! do not use this, do not use it, dont use itttt! lol //
|
||||
// you have been warned. //
|
||||
|
||||
private SHA256(){};
|
||||
|
||||
public static String hash(String raw) throws NoSuchAlgorithmException {
|
||||
MessageDigest dig = MessageDigest.getInstance("SHA-256");
|
||||
|
||||
byte[] res = dig.digest(raw.getBytes(StandardCharsets.UTF_8));
|
||||
StringBuilder hex = new StringBuilder();
|
||||
for (byte b :res) {
|
||||
hex.append(String.format("%02x", b));
|
||||
}
|
||||
|
||||
return hex.toString();
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user