标签:
public static String getSignature(String s) throws NoSuchAlgorithmException, UnsupportedEncodingException, InvalidKeyException {
// String Token = "O-xJVg7ZEXrtjWDNhzu05R7iZtyyXmv6NGt-xymKg0eOLCwwBCIgBBaDqJabzbPVCez1BvcI8q7blDGy4ZeCQQ";
String key = "O-xJVg7ZEXrtjWDNhzu05R7iZtyyXmv6NGt-xymKg0eOLCwwBCIgBBaDqJabzbPVCez1BvcI8q7blDGy4ZeCQQ";
System.out.println(key);
String request = s.toLowerCase();
Mac mac = Mac.getInstance("HmacSHA1");
SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(), "HmacSHA1");
mac.init(keySpec);
mac.update(request.getBytes());
byte[] encryptedBytes = mac.doFinal();
return Base64.encodeBase64String(encryptedBytes);
}
标签:
原文地址:http://www.cnblogs.com/xiaojiayu/p/5410604.html