Comparing version 1.0.0 to 2.0.0
55
index.js
@@ -1,8 +0,5 @@ | ||
var fs = require("fs"); | ||
const fs = require("fs"); | ||
const reference = JSON.parse(fs.readFileSync('./asciiReferenceReverse.json')); | ||
const asciiReference = JSON.parse(fs.readFileSync('./asciiReference.json')); | ||
function sleep(time) { | ||
return new Promise((resolve) => setTimeout(resolve, time)); | ||
} | ||
function getKeyByValue(object, value) { | ||
@@ -50,5 +47,2 @@ return Object.keys(object).find(key => object[key] === value); | ||
const { hash, maxAttempt, attempt } = this | ||
if (attempt > maxAttempt) { | ||
await sleep(1000 * attempt); | ||
} | ||
const tokenArray = [...token]; | ||
@@ -79,3 +73,46 @@ let compareHash = this.createHash(word, tokenArray); | ||
} | ||
const ecrypt = (token, target) => { | ||
module.exports = Ecrypt; | ||
const rotateAscii = (...charKeys) => { | ||
const min = 33, max = 126; | ||
const keys = [...charKeys]; | ||
const total = keys.reduce((accumulator, currentValue) => accumulator + parseInt(currentValue), 0) | ||
if (total <= max) { | ||
return asciiReference[total]; | ||
} else { | ||
let percentage = (parseInt(total) % parseInt(max)) + min | ||
while (percentage > max) { | ||
percentage = (parseInt(total) % percentage) + min; | ||
} | ||
return asciiReference[percentage] | ||
} | ||
} | ||
const compareTokenAndTarget = (token, word) => { | ||
if (token.length < word.length) | ||
return { array: [...word], merge: [...token], length: token.length }; | ||
return { array: [...token], merge: [...word], length: token.length }; | ||
} | ||
const merge = (response) => { | ||
const { array, merge, length } = response; | ||
let counter = 0; | ||
const keys = []; | ||
array.forEach(item => { | ||
if (counter === length) | ||
counter = 0; | ||
console.log(counter) | ||
if (!keys[counter]) | ||
keys.push(rotateAscii(reference[item], reference[merge[counter]])); | ||
else | ||
keys[counter] = (rotateAscii(reference[item], reference[merge[counter]], reference[keys[counter]])); | ||
counter++; | ||
}) | ||
return keys.join('') | ||
} | ||
const response = compareTokenAndTarget(token, target) | ||
return merge(response) | ||
} | ||
module.exports = { Ecrypt, ecrypt }; |
{ | ||
"name": "ecrypt", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "", | ||
@@ -14,2 +14,2 @@ "main": "index.js", | ||
} | ||
} | ||
} |
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
9286
5
372
3