Skip to content

Commit

Permalink
don't use lib/use languages/, command line options
Browse files Browse the repository at this point in the history
  • Loading branch information
odilitime committed Feb 8, 2019
1 parent 6e3d412 commit af3cdc1
Showing 1 changed file with 19 additions and 103 deletions.
122 changes: 19 additions & 103 deletions strip.js
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(""))

0 comments on commit af3cdc1

Please sign in to comment.