cryptx
Version:
An easy password manager
46 lines (34 loc) • 1.25 kB
JavaScript
var shell = require('shelljs');
var prompt = require('prompt');
shell.exec('echo swag')
prompt.start();
prompt.get(['password'], function(err, result) {
treshold = 10000000000;
c = {
0: [], // input encoded
1: [], // key encoded
2: [], // cipher encoded
3: [], // decoded encoded
4: [] // decoded password
};
for (i=0;i<=result.password.length;++i) c[0].push((result.password[i]+"").charCodeAt(0));
console.log("Encoded input: " + c[0].join(", "));
// c[0] is input
// generate challenge key
for (i=0;i<=c[0].length;++i) c[1].push(Math.round(Math.random()*treshold));
console.log("Generated Challenge Pad: " + c[1].join(", "));
// generate cipher
for (i=0;i<=c[0].length;++i) c[2].push(c[0][i] ^ c[1][i]);
console.log("Resulting Cipher: " + c[2].join(", "));
for (i=0;i<=c[0].length - 1;++i) c[3].push(c[2][i] ^ c[1][i]);
console.log("Recalculated Pad: " + c[3].join(", "));
console.log("Has decoding been successful? " + ( c[0].join() == c[3].join() ? "Yes" : "No" ));
for(i=0;i<c[0].length-1;++i)
{
c[4].push(String.fromCharCode(c[3][i]));
}
console.log(c[4].join(""));
console.log("Please enter the service for which you require this password");
prompt.get(['service'], function(err, result){
});
});