2016-11-27 15:46:42 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var CryptoJS = require('crypto-js');
|
|
|
|
|
|
|
|
exports.hmacSha3 = function(msg, key) {
|
2016-12-03 02:14:13 +00:00
|
|
|
var hmac = CryptoJS.HmacSHA3(msg, key);
|
|
|
|
//console.log("bla");
|
|
|
|
//console.log(hmac.toString());
|
|
|
|
//console.log(CryptoJS.enc.Utf8.stringify(hmac));
|
2016-11-27 15:46:42 +00:00
|
|
|
return hmac.toString();
|
|
|
|
}
|
2016-11-30 20:22:35 +00:00
|
|
|
|
|
|
|
exports.setLocation = function(newLoc) {
|
2016-12-03 02:14:13 +00:00
|
|
|
window.location = newLoc;
|
2016-11-30 20:22:35 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.getAttr = function(attr) {
|
|
|
|
return function(ob) {
|
|
|
|
return function() {
|
2016-12-03 02:14:13 +00:00
|
|
|
return ob.attr(attr);
|
2016-11-30 20:22:35 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2016-12-03 02:14:13 +00:00
|
|
|
|
|
|
|
exports.toHex = function(str) {
|
|
|
|
var repr = parseInt(str, 16);
|
|
|
|
return repr.toString(16);
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.fromHex = function(str) {
|
|
|
|
return CryptoJS.enc.Hex.parse(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.fromUtf8 = function(str) {
|
|
|
|
return CryptoJS.enc.Utf8.parse(str);
|
|
|
|
}
|