Comparing version 1.1.0 to 1.2.0
@@ -7,2 +7,6 @@ # Change Log | ||
## [1.2.0] - 2017-06-10 | ||
### Added | ||
- Static methods MD5 and SHA1 | ||
## [1.1.0] - 2017-06-07 | ||
@@ -9,0 +13,0 @@ ### Added |
{ | ||
"name": "cryptorjs", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Encrypt and decrypt string, number and object using a key", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -69,2 +69,15 @@ # Cryptorjs | ||
### MD5 and SHA1 helpers | ||
```javascript | ||
var cryptorjs = require('cryptorjs'); | ||
cryptorjs.md5('ciao'); | ||
/*=> '6e6bc4e49dd477ebc98ef4046c067b5f'*/ | ||
cryptorjs.sha1('ciao'); | ||
/*=> '1e4e888ac66f8dd41e00c5a7ac36a32a9950d271'*/ | ||
``` | ||
## License | ||
@@ -71,0 +84,0 @@ Cryptorjs is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) |
@@ -19,3 +19,2 @@ /** | ||
constructor(key, algorithm = 'aes-256-ctr'){ | ||
if(typeof key === 'undefined') | ||
@@ -61,2 +60,20 @@ throw new Error('required key'); | ||
} | ||
/** | ||
* MD5 hash | ||
* @param str | ||
* @returns {*} | ||
*/ | ||
static md5(str){ | ||
return crypto.createHash('md5').update(str).digest('hex'); | ||
} | ||
/** | ||
* SHA1 hash | ||
* @param str | ||
* @returns {*} | ||
*/ | ||
static sha1(str){ | ||
return crypto.createHash('sha1').update(str).digest('hex'); | ||
} | ||
} | ||
@@ -63,0 +80,0 @@ |
/** | ||
* Created by Fabio on 07/06/2017. | ||
*/ | ||
const crypto = require('crypto'); | ||
@@ -5,0 +6,0 @@ /** |
@@ -152,2 +152,17 @@ /** | ||
}); | ||
describe('hash helper', function () { | ||
it('should be return md5 hash', function () { | ||
let origin = 'ciao'; | ||
let result = cryptor.md5(origin); | ||
console.log(origin, result); | ||
assert.equal(result, '6e6bc4e49dd477ebc98ef4046c067b5f'); | ||
}); | ||
it('should be return sha1 hash', function () { | ||
let origin = 'ciao'; | ||
let result = cryptor.sha1(origin); | ||
console.log(origin, result); | ||
assert.equal(result, '1e4e888ac66f8dd41e00c5a7ac36a32a9950d271'); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
11498
246
86
0