base project
This commit is contained in:
1
node_modules/secure-compare/.npmignore
generated
vendored
Normal file
1
node_modules/secure-compare/.npmignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules
|
35
node_modules/secure-compare/README.md
generated
vendored
Normal file
35
node_modules/secure-compare/README.md
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
# secure-compare
|
||||
|
||||
Constant-time comparison algorithm to prevent timing attacks for Node.js.
|
||||
Copied from [cryptiles](https://github.com/hapijs/cryptiles) by [C J Silverio](https://github.com/ceejbot).
|
||||
|
||||
|
||||
### Installation
|
||||
|
||||
```
|
||||
$ npm install secure-compare --save
|
||||
```
|
||||
|
||||
|
||||
### Usage
|
||||
|
||||
```javascript
|
||||
var compare = require('secure-compare');
|
||||
|
||||
compare('hello world', 'hello world').should.equal(true);
|
||||
compare('你好世界', '你好世界').should.equal(true);
|
||||
|
||||
compare('hello', 'not hello').should.equal(false);
|
||||
```
|
||||
|
||||
|
||||
### Tests
|
||||
|
||||
```
|
||||
$ npm test
|
||||
```
|
||||
|
||||
|
||||
### License
|
||||
|
||||
secure-compare is released under the MIT license.
|
25
node_modules/secure-compare/index.js
generated
vendored
Executable file
25
node_modules/secure-compare/index.js
generated
vendored
Executable file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Expose secure-compare
|
||||
*/
|
||||
|
||||
module.exports = compare;
|
||||
|
||||
|
||||
/**
|
||||
* Secure compare
|
||||
*/
|
||||
|
||||
function compare (a, b) {
|
||||
if (typeof a !== 'string' || typeof b !== 'string') return false;
|
||||
|
||||
var mismatch = a.length === b.length ? 0 : 1;
|
||||
if (mismatch) {
|
||||
b = a;
|
||||
}
|
||||
|
||||
for (var i = 0, il = a.length; i < il; ++i) {
|
||||
mismatch |= (a.charCodeAt(i) ^ b.charCodeAt(i));
|
||||
}
|
||||
|
||||
return mismatch === 0;
|
||||
};
|
27
node_modules/secure-compare/package.json
generated
vendored
Normal file
27
node_modules/secure-compare/package.json
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "secure-compare",
|
||||
"version": "3.0.1",
|
||||
"description": "Securely compare two strings, copied from cryptiles",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "./node_modules/.bin/mocha test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/vdemedes/secure-compare.git"
|
||||
},
|
||||
"keywords": [
|
||||
"secure",
|
||||
"compare"
|
||||
],
|
||||
"author": "Vadim Demedes <vdemedes@gmail.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/vdemedes/secure-compare/issues"
|
||||
},
|
||||
"homepage": "https://github.com/vdemedes/secure-compare",
|
||||
"devDependencies": {
|
||||
"chai": "^2.2.0",
|
||||
"mocha": "^2.2.1"
|
||||
}
|
||||
}
|
19
node_modules/secure-compare/test.js
generated
vendored
Normal file
19
node_modules/secure-compare/test.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Dependencies
|
||||
*/
|
||||
|
||||
var compare = require('./');
|
||||
|
||||
require('chai').should();
|
||||
|
||||
|
||||
/**
|
||||
* Tests
|
||||
*/
|
||||
|
||||
describe ('secure-compare', function () {
|
||||
it ('compare', function () {
|
||||
compare('abc', 'abc').should.equal(true);
|
||||
compare('abc', 'ab').should.equal(false);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user