Skip to content

Commit fa20bae

Browse files
committed
Switched to crypto-js
Old library was producing invalid signatures often
1 parent 07a9990 commit fa20bae

File tree

4 files changed

+24
-321
lines changed

4 files changed

+24
-321
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<link href="styles/styles.css" rel="stylesheet" type="text/css" />
1313

1414
<!-- Libraries and helper scripts -->
15-
<script src="scripts/jssha256.js" type="text/javascript"></script>
15+
<script src="scripts/hmac-sha256.js" type="text/javascript"></script>
1616
<script src="scripts/jquery-2.0.3.min.js" type="text/javascript"></script>
1717
<script src="scripts/numeral.min.js" type="text/javascript"></script>
1818
<script src="scripts/bitstamp-js.js" type="text/javascript"></script>

scripts/bitstamp-js.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ Bitstamp.prototype.submitRequest = function(bitstampmethod, callback, params) {
105105

106106
unix_timestamp = Math.round(+new Date());
107107
message = unix_timestamp.toString() + this.auth.client_id + this.auth.api_key;
108-
//console.log(message);
109-
signature = HMAC_SHA256_MAC(this.auth.api_secret, message);
110-
//console.log(signature);
111-
signature = signature.toUpperCase();
112-
//console.log(signature);
108+
109+
var hmac = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, this.auth.api_secret);
110+
hmac.update(message);
111+
var hash = hmac.finalize();
112+
signature = hash.toString().toUpperCase();
113113

114114
params.key = this.auth.api_key;
115115
params.signature = signature;

scripts/hmac-sha256.js

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/jssha256.js

Lines changed: 0 additions & 315 deletions
This file was deleted.

0 commit comments

Comments
 (0)