Skip to content

Commit

Permalink
(This commit resolves issue aws-amplify#315 (aws-amplify#315). The fi…
Browse files Browse the repository at this point in the history
…x was that encodeBase64 required its flags to be updated to include Base64.NO_PADDING)
  • Loading branch information
leonard committed Nov 11, 2017
1 parent 4a5b1db commit 2393d58
Showing 1 changed file with 2 additions and 2 deletions.
Expand Up @@ -48,7 +48,7 @@ public final static String generateRandom() {
public final static String generateHash(String data) throws Exception {
String hashedData = data;
try {
byte[] bytes = data.getBytes("US-ASCII");
byte[] bytes = data.getBytes(StandardCharsets.US_ASCII);
MessageDigest digest = MessageDigest.getInstance("SHA-256");
digest.update(bytes, 0, bytes.length);
byte[] digestBytes = digest.digest();
Expand All @@ -69,6 +69,6 @@ public final static String encodeBase64(String str) {
return null;
}
byte[] data = str.getBytes(Charset.forName("ISO-8859-1"));
return Base64.encodeToString(data, Base64.NO_PADDING);
return Base64.encodeToString(data, Base64.URL_SAFE | Base64.NO_WRAP | Base64.NO_PADDING);
}
}

0 comments on commit 2393d58

Please sign in to comment.