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); }
时间: 2024-10-04 22:29:59