Initial Lineups
This commit is contained in:
parent
6d2994d571
commit
3c3d23c337
21
index.js
21
index.js
|
@ -1 +1,20 @@
|
|||
console.log("Hello World")
|
||||
const Cryptr = require("cryptr");
|
||||
|
||||
function Randomizer(secret) {
|
||||
const ts = new Date().toUTCString();
|
||||
if (!secret || typeof secret !== "string") {
|
||||
throw new Error("Cryptr: secret must be a non-0-length string");
|
||||
}
|
||||
const cryptr = new Cryptr(secret);
|
||||
|
||||
const encryptedTs = cryptr.encrypt(ts);
|
||||
console.log(encryptedTs);
|
||||
this.showKey = function showKey() {
|
||||
return secret;
|
||||
};
|
||||
this.getTs = function getTs() {
|
||||
return ts;
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = Randomizer;
|
||||
|
|
17
package.json
17
package.json
|
@ -4,7 +4,8 @@
|
|||
"description": "A Random string encryptor w.r.t timestamp",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"hello": "echo hello world !!",
|
||||
"test": "node ./test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -24,5 +25,17 @@
|
|||
"bugs": {
|
||||
"url": "https://github.com/bravo68web/randomizer/issues"
|
||||
},
|
||||
"homepage": "https://github.com/bravo68web/randomizer#readme"
|
||||
"homepage": "https://github.com/bravo68web/randomizer#readme",
|
||||
"dependencies": {
|
||||
"crypto-js": "^4.0.0",
|
||||
"cryptr": "^6.0.2",
|
||||
"jose": "^3.14.0",
|
||||
"randomstring": "^1.2.1",
|
||||
"string-crypto": "^2.0.1",
|
||||
"tape": "^5.2.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"grunt": "^1.4.1",
|
||||
"webpack": "^5.44.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
const test = require("tape");
|
||||
const Randomizer = require("../");
|
||||
|
||||
const testSecret = "myTotalySecretKey";
|
||||
const testData = "bacon";
|
||||
|
||||
test("Initialization...", (t) => {
|
||||
t.plan(1);
|
||||
const Randomizr = new Randomizer(testSecret);
|
||||
checkKey = Randomizr.showKey();
|
||||
t.equal(checkKey, testSecret, "Key Mention can be Used");
|
||||
});
|
||||
|
||||
test("Checking Timestamps...", (t) => {
|
||||
t.plan(1);
|
||||
const Randomizr = new Randomizer(testSecret);
|
||||
var currentTs = new Date().toUTCString();
|
||||
var innerTs = Randomizr.getTs();
|
||||
t.equal(currentTs, innerTs, "TimeStamp Matched");
|
||||
});
|
|
@ -0,0 +1,10 @@
|
|||
// console.log(new Date().toUTCString());
|
||||
const Cryptr = require("cryptr");
|
||||
const appEncryptKey =
|
||||
"jWThgBwk4Awh7QQ82GDaz5QFcnVULu9Nk8bnU8sH6LcnfWfpeNaeYDLNGhSU47Yy";
|
||||
const cryptr = new Cryptr(appEncryptKey);
|
||||
currentTs = new Date().toUTCString();
|
||||
const encryptedString = cryptr.encrypt(currentTs);
|
||||
const decryptedString = cryptr.decrypt(encryptedString);
|
||||
|
||||
console.log(encryptedString);
|
Loading…
Reference in New Issue