Skip to content

Commit

Permalink
Updating just cause...
Browse files Browse the repository at this point in the history
  • Loading branch information
devgeeks committed Oct 24, 2020
1 parent 1c0e122 commit eed9d9e
Show file tree
Hide file tree
Showing 9 changed files with 4,521 additions and 32 deletions.
10 changes: 9 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
{
"presets": ["env"]
"presets": [
[
"@babel/preset-env",
{
"useBuiltIns": "usage",
"corejs": "3"
}
]
]
}
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"bracketSpacing": false,
"printWidth": 120
}
4,112 changes: 4,112 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

30 changes: 13 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,23 @@
"description": "Crypton is dead, long live Echidna.js",
"main": "lib/index.js",
"dependencies": {
"babel-polyfill": "^6.23.0",
"fast-sha256": "^1.0.0",
"pouchdb": "^6.2.0",
"pouchdb-find": "^6.2.0",
"transform-pouch": "^1.1.3",
"tweetnacl": "^1.0.0",
"tweetnacl-util": "^0.15.0"
"@babel/polyfill": "^7.0.0",
"core-js": "^3.6.5",
"fast-sha256": "^1.3.0",
"pouchdb": "^7.2.2",
"pouchdb-find": "^7.2.2",
"transform-pouch": "^1.1.5",
"tweetnacl": "^1.0.3",
"tweetnacl-util": "^0.15.1"
},
"devDependencies": {
"babel-cli": "^6.24.0",
"babel-preset-env": "^1.2.2",
"babel-preset-es2015": "^6.24.0",
"eslint": "^3.17.1",
"eslint-config-airbnb": "^14.1.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^4.0.0",
"eslint-plugin-react": "^6.10.0",
"rimraf": "^2.6.1"
"@babel/core": "^7.12.0",
"@babel/cli": "^7.12.0",
"@babel/preset-env": "^7.12.0",
"rimraf": "^3.0.2"
},
"scripts": {
"build": "babel src --presets babel-preset-es2015 --out-dir lib",
"build": "babel src --out-dir lib",
"prepublish": "npm run build",
"test": "node test/node-test/test.js"
},
Expand Down
7 changes: 2 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,12 @@ export function generateNonce() {
}

export function keyFromPassphrase(passphrase, salt, rounds = 100000) {
const key = sha256.pbkdf2(
nacl.util.decodeUTF8(passphrase),
nacl.util.decodeUTF8(salt),
rounds, 32);
const key = sha256.pbkdf2(nacl.util.decodeUTF8(passphrase), nacl.util.decodeUTF8(salt), rounds, 32);
return key;
}

export default class Echidnajs {
constructor({ username, passphrase, salt, rounds = 100000 }) {
constructor({username, passphrase, salt, rounds = 100000}) {
if (!username || !passphrase || !salt) {
throw new Error('Missing required options');
return false;
Expand Down
361 changes: 361 additions & 0 deletions tags

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions test/node-test/test.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
var rimraf = require('rimraf');
var EchidnaDB = require('../../lib').default;
var setup = require('./setup');
const rimraf = require('rimraf');
const EchidnaDB = require('../../lib').default;
const setup = require('./setup');

function error (error) {
console.log(error);
console.log('<< REMOVING TEST POUCH >>');
rimraf('echidnadb-myusername', () => console.log('complete'));
}

setup()
.then(res => {
var options = {
const options = {
username: 'myusername',
passphrase: 'mypassphrase',
salt: 'saltysaltysalty'
};
var echidna = new EchidnaDB(options);
console.log('<< CREATING TEST POUCH >>');
const echidna = new EchidnaDB(options);

echidna.pouch.info()
.then(result => {
console.log(result);
echidna.pouch.get('test')
.then(res => {
console.log(res);
console.log('<< REMOVING TEST POUCH >>');
rimraf('echidnadb-myusername', () => console.log('complete'));
})
.catch(error);
})
.catch(error);
});
});
})
.catch(error);
9 changes: 9 additions & 0 deletions test/quick-node-time-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
var book = require('./data').book;
var nacl = require('tweetnacl');
var fs = require('fs');
var file = fs.readFileSync('./tommy-carlos--williams.png', "utf8");
nacl.util = require('tweetnacl-util');
var sha256 = require('fast-sha256');

Expand Down Expand Up @@ -28,3 +30,10 @@ nonce = nacl.randomBytes(24);
box = nacl.secretbox(nacl.util.decodeUTF8(book), nonce, key);
console.timeEnd('Encrypt Thomas Paine Books');
console.log('\nNow thats a lot of data!');


console.time('Encrypt Image');
nonce = nacl.randomBytes(24);
box = nacl.secretbox(nacl.util.decodeUTF8(file), nonce, key);
console.timeEnd('Encrypt Image');
console.log('\nNow thats a lot more data!');
Binary file added test/tommy-carlos--williams.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit eed9d9e

Please sign in to comment.