MCPcopy Create free account
hub / github.com/MediaArea/MediaInfoLib / calculateHmacSHA1

Method calculateHmacSHA1

Source/Example/HowToUse_Dll.java:263–279  ·  view source on GitHub ↗

Computes HMAC signature. @param data The data to be signed. @param secretKey The signing secret key. @return The Base64-encoded HMAC signature. @throws java.security.SignatureException when signature generation fails

(String data, String secretKey)

Source from the content-addressed store, hash-verified

261* @throws java.security.SignatureException when signature generation fails
262*/
263private static String calculateHmacSHA1(String data, String secretKey)
264throws java.security.SignatureException
265{
266 String Result;
267
268 try
269 {
270 Mac mac = Mac.getInstance("HmacSHA1"); // Create an HMAC instance
271 mac.init(new SecretKeySpec(secretKey.getBytes(), "HmacSHA1")); // Initialize the HMAC instance with the secret key
272 Result = Base64.getEncoder().encodeToString(mac.doFinal(data.getBytes()));
273 }
274 catch (Exception e)
275 {
276 throw new SignatureException(e.getMessage());
277 }
278 return Result;
279}
280
281}

Callers 1

ByBuffer_URLMethod · 0.95

Calls 1

initMethod · 0.80

Tested by

no test coverage detected