Files
codeql/java/ql/test/experimental/query-tests/security/CWE-759/SHA256.java
2021-01-18 19:22:34 +00:00

21 lines
570 B
Java

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class SHA256 implements HASH {
MessageDigest md;
public int getBlockSize() {return 32;}
public void init() throws NoSuchAlgorithmException {
try { md = MessageDigest.getInstance("SHA-256"); }
catch (Exception e){
System.err.println(e);
}
}
public void update(byte[] foo, int start, int len) throws NoSuchAlgorithmException {
md.update(foo, start, len);
}
public byte[] digest() throws NoSuchAlgorithmException {
return md.digest();
}
}