有能将以下这段java代码翻译成GO语言的大神么 求助
求助大咖们:
public static String sign1(byte[] data, long timestamp, PrivateKey key) throws Exception {
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(data);
if (timestamp > 0) {
byte[] buffer = new byte[8];
buffer[0] = (byte) (timestamp >>> 56);
buffer[1] = (byte) (timestamp >>> 48);
buffer[2] = (byte) (timestamp >>> 40);
buffer[3] = (byte) (timestamp >>> 32);
buffer[4] = (byte) (timestamp >>> 24);
buffer[5] = (byte) (timestamp >>> 16);
buffer[6] = (byte) (timestamp >>> 8);
buffer[7] = (byte) (timestamp >>> 0);
md.update(buffer);
}
byte[] hash = md.digest();
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] encrypted = cipher.doFinal(hash);
return HexBin.encode(encrypted);
}
以上实现逻辑是:1.先将字符串做hash; 2. 用户私钥对hash做加密(注意是私钥)3. 加密的结果用hex进行编码
其中私钥是用户在pfx证书中读取的私钥;