From af3cdc1751711cee6110d07d7f9c239d68bec982 Mon Sep 17 00:00:00 2001 From: Odilitime Date: Fri, 8 Feb 2019 13:11:43 -0800 Subject: [PATCH] don't use lib/use languages/, command line options --- strip.js | 122 +++++++++---------------------------------------------- 1 file changed, 19 insertions(+), 103 deletions(-) diff --git a/strip.js b/strip.js index 903a3dd..a5b2490 100644 --- a/strip.js +++ b/strip.js @@ -1,112 +1,28 @@ -const language_frequency = require('./lib/frequency_en.js') const charset2homophones = require('./lib/generator.js') const encrypt = require('./lib/encrypt.js') const decrypt = require('./lib/decrypt.js') -var our_charset = [ - 'a', - 'b', - 'c', - 'd', - 'e', - 'f', - 'g', - 'h', - 'i', - 'j', - 'k', - 'l', - 'm', - 'n', - 'o', - 'p', - 'q', - 'r', - 's', - 't', - 'u', - 'v', - 'w', - 'x', - 'y', - 'z', - '[', - ']', - '\\', - ';', - '\'', - ',', - '.', - '/', - '`', - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - '0', - '-', - '=', - 'ยง', - ' ', - 'A', - 'B', - 'C', - 'D', - 'E', - 'F', - 'G', - 'H', - 'I', - 'J', - 'K', - 'L', - 'M', - 'N', - 'O', - 'P', - 'Q', - 'R', - 'S', - 'T', - 'U', - 'V', - 'W', - 'X', - 'Y', - 'Z', - '{', - '}', - '|', - ':', - '"', - '<', - '>', - '?', - '~', - '!', - '@', - '#', - '$', - '%', - '^', - '&', - '*', - '(', - ')', - '_', - '+', - '\n', - '\t', -] +// string +var string = process.argv[2] +if (string === undefined) string = 'The job requires extra pluck and zeal from every young wage earner. ' -var homophones = charset2homophones(language_frequency, our_charset, 394) +// strength +var max = process.argv[3] +if (max === undefined) max = 394 + +// frequency +var languageFile = process.argv[4] +if (languageFile === undefined) languageFile = 'languages/frequency_en.json' +const language_frequency = JSON.parse(fs.readFileSync(languageFile)) + +// actual subset +var charsetFile = process.argv[5] +if (charsetFile === undefined) charsetFile = 'languages/charset_en.json' +const our_charset = JSON.parse(fs.readFileSync(charsetFile)) + +var homophones = charset2homophones(language_frequency, our_charset, max) console.dir(homophones) -var test = encrypt('The job requires extra pluck and zeal from every young wage earner. ', homophones) +var test = encrypt(string, homophones) console.log(test) var result = decrypt(test, homophones) console.log(result.join(""))