-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
don't use lib/use languages/, command line options
- Loading branch information
Showing
1 changed file
with
19 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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("")) |