mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-23 03:28:07 +00:00
sha3 backward compatibility. #205
This commit is contained in:
parent
3fb420f63c
commit
3bb6e4f723
13
dist/web3-light.js
vendored
13
dist/web3-light.js
vendored
@ -820,16 +820,25 @@ module.exports = {
|
||||
* @date 2015
|
||||
*/
|
||||
|
||||
var utils = require('./utils');
|
||||
var sha3 = require('crypto-js/sha3');
|
||||
|
||||
module.exports = function (str) {
|
||||
module.exports = function (str, isNew) {
|
||||
if (str.substr(0, 2) === '0x' && !isNew) {
|
||||
console.warn('requirement of using web3.fromAscii before sha3 is deprecated');
|
||||
console.warn('new usage: \'web3.sha3("hello")\'');
|
||||
console.warn('see https://github.com/ethereum/web3.js/pull/205');
|
||||
console.warn('if you need to hash hex value, you can do \'sha3("0xfff", true)\'');
|
||||
str = utils.toAscii(str);
|
||||
}
|
||||
|
||||
return sha3(str, {
|
||||
outputLength: 256
|
||||
}).toString();
|
||||
};
|
||||
|
||||
|
||||
},{"crypto-js/sha3":30}],7:[function(require,module,exports){
|
||||
},{"./utils":7,"crypto-js/sha3":30}],7:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
|
4
dist/web3-light.js.map
vendored
4
dist/web3-light.js.map
vendored
File diff suppressed because one or more lines are too long
5
dist/web3-light.min.js
vendored
5
dist/web3-light.min.js
vendored
File diff suppressed because one or more lines are too long
13
dist/web3.js
vendored
13
dist/web3.js
vendored
@ -820,16 +820,25 @@ module.exports = {
|
||||
* @date 2015
|
||||
*/
|
||||
|
||||
var utils = require('./utils');
|
||||
var sha3 = require('crypto-js/sha3');
|
||||
|
||||
module.exports = function (str) {
|
||||
module.exports = function (str, isNew) {
|
||||
if (str.substr(0, 2) === '0x' && !isNew) {
|
||||
console.warn('requirement of using web3.fromAscii before sha3 is deprecated');
|
||||
console.warn('new usage: \'web3.sha3("hello")\'');
|
||||
console.warn('see https://github.com/ethereum/web3.js/pull/205');
|
||||
console.warn('if you need to hash hex value, you can do \'sha3("0xfff", true)\'');
|
||||
str = utils.toAscii(str);
|
||||
}
|
||||
|
||||
return sha3(str, {
|
||||
outputLength: 256
|
||||
}).toString();
|
||||
};
|
||||
|
||||
|
||||
},{"crypto-js/sha3":30}],7:[function(require,module,exports){
|
||||
},{"./utils":7,"crypto-js/sha3":30}],7:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
|
4
dist/web3.js.map
vendored
4
dist/web3.js.map
vendored
File diff suppressed because one or more lines are too long
5
dist/web3.min.js
vendored
5
dist/web3.min.js
vendored
File diff suppressed because one or more lines are too long
@ -20,9 +20,18 @@
|
||||
* @date 2015
|
||||
*/
|
||||
|
||||
var utils = require('./utils');
|
||||
var sha3 = require('crypto-js/sha3');
|
||||
|
||||
module.exports = function (str) {
|
||||
module.exports = function (str, isNew) {
|
||||
if (str.substr(0, 2) === '0x' && !isNew) {
|
||||
console.warn('requirement of using web3.fromAscii before sha3 is deprecated');
|
||||
console.warn('new usage: \'web3.sha3("hello")\'');
|
||||
console.warn('see https://github.com/ethereum/web3.js/pull/205');
|
||||
console.warn('if you need to hash hex value, you can do \'sha3("0xfff", true)\'');
|
||||
str = utils.toAscii(str);
|
||||
}
|
||||
|
||||
return sha3(str, {
|
||||
outputLength: 256
|
||||
}).toString();
|
||||
|
@ -1,6 +1,7 @@
|
||||
var chai = require('chai');
|
||||
var assert = chai.assert;
|
||||
var sha3 = require('../lib/utils/sha3');
|
||||
var web3 = require('../index');
|
||||
|
||||
describe('lib/utils/sha3', function () {
|
||||
var test = function (v, e) {
|
||||
@ -11,5 +12,6 @@ describe('lib/utils/sha3', function () {
|
||||
|
||||
test('test123', 'f81b517a242b218999ec8eec0ea6e2ddbef2a367a14e93f4a32a39e260f686ad');
|
||||
test('test(int)', 'f4d03772bec1e62fbe8c5691e1a9101e520e8f8b5ca612123694632bf3cb51b1');
|
||||
test(web3.fromAscii('test123'), 'f81b517a242b218999ec8eec0ea6e2ddbef2a367a14e93f4a32a39e260f686ad');
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user