Permalink
Browse files

fixed authentication signature

  • Loading branch information...
1 parent b27a916 commit 165552329590ca5f6139afdde783f5c2711e7390 stephan committed Oct 16, 2010
Showing with 5 additions and 3 deletions.
  1. +5 −3 Pusher.java
View
@@ -66,7 +66,7 @@ private static String byteArrayToString(byte[] data){
}
return hash;
}
-
+
/**
* Returns a md5 representation of the given string
* @param data
@@ -97,14 +97,16 @@ private static String hmacsha256Representation(String data) {
// Create the HMAC/SHA256 key from application secret
final SecretKeySpec signingKey = new SecretKeySpec( pusherApplicationSecret.getBytes(), "HmacSHA256");
- // Create the message authentication code (MAC)
+ // Create the message authentication code (MAC)
final Mac mac = Mac.getInstance("HmacSHA256");
mac.init(signingKey);
//Process and return data
byte[] digest = mac.doFinal(data.getBytes("UTF-8"));
digest = mac.doFinal(data.getBytes());
- return byteArrayToString(digest);
+ //Convert to string
+ BigInteger bigInteger = new BigInteger(1,digest);
+ return String.format("%0" + (digest.length << 1) + "x", bigInteger);
} catch (NoSuchAlgorithmException nsae) {
//We should never come here, because GAE has HMac SHA256
throw new RuntimeException("No HMac SHA256 algorithm");

0 comments on commit 1655523

Please sign in to comment.