Skip to content

Instantly share code, notes, and snippets.

@NestorHuang
Last active July 31, 2019 09:11
Show Gist options
  • Save NestorHuang/758d10a2977627f9ecd0a12e593d61d1 to your computer and use it in GitHub Desktop.
Save NestorHuang/758d10a2977627f9ecd0a12e593d61d1 to your computer and use it in GitHub Desktop.
e首發票Signature Java版 Ver2
import java.util.*;
import java.math.BigInteger;
import java.security.MessageDigest;
public class Main {
public static void main(String[] args) throws Exception {
String _timeStamp = "1496419339";
String _hashSalt = "909043347504457A92EA5565778A26C6";
System.out.println(getSHA256(_timeStamp+_hashSalt));
}
public static String getSHA256(String input){
String toReturn = null;
try {
MessageDigest digest = MessageDigest.getInstance("SHA-256");
digest.reset();
digest.update(input.getBytes("utf8"));
toReturn = String.format("%064x", new BigInteger(1, digest.digest()));
} catch (Exception e) {
e.printStackTrace();
}
return toReturn;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment