This repository has been archived by the owner on Jun 13, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
common.js
85 lines (68 loc) · 3.51 KB
/
common.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
var _ = require('lodash')
var jsesc = require('jsesc')
var punycode = require('punycode')
var chars = require('./libs/crypto-lib/char-list.js')
// var chars = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~£¥¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'
console.log('chars ', chars)
var CryptoLib = require('./libs/crypto-lib.js')
// var encryptedText = CryptoLib.encrypt(chars, '🍘')
// console.log('encrypt', encryptedText)
// console.log('decrypt', CryptoLib.decrypt(encryptedText, '🍘'))
// CryptoLib.generateEmojiSubsetFrom('🍘')
// var encryptedText = CryptoLib.encrypt('this is a text', '🍘')
// console.log('encrypt', encryptedText)
// console.log('decrypt', CryptoLib.decrypt(encryptedText, '🍘'))
var clearText = 'this is a text bau bau!!!'
CryptoLib.generateEmojiSubsetFrom('🍎')
var encryptedText = CryptoLib.encrypt(clearText, '🍎')
console.log('Cryptoloji with key 🍎')
console.log('encrypt', encryptedText)
console.log('decrypt', CryptoLib.decrypt(encryptedText, '🍎'))
CryptoLib.generateEmojiSubsetFrom('🐝')
var encryptedText = CryptoLib.encrypt(clearText, '🐝')
console.log('Cryptoloji with key 🐝')
console.log('encrypt', encryptedText)
console.log('decrypt', CryptoLib.decrypt(encryptedText, '🐝'))
CryptoLib.generateEmojiSubsetFrom('💣')
var encryptedText = CryptoLib.encrypt(clearText, '💣')
console.log('Cryptoloji with key 💣')
console.log('encrypt', encryptedText)
console.log('decrypt', CryptoLib.decrypt(encryptedText, '💣'))
CryptoLib.generateEmojiSubsetFrom('🚝')
var encryptedText = CryptoLib.encrypt(clearText, '🚝')
console.log('Cryptoloji with key 🚝')
console.log('encrypt', encryptedText)
console.log('decrypt', CryptoLib.decrypt(encryptedText, '🚝'))
console.log('decrypt', CryptoLib.decrypt(encryptedText, '💺'))
CryptoLib.generateEmojiSubsetFrom('💺')
var encryptedText = CryptoLib.encrypt(clearText, '💺')
console.log('Cryptoloji with key 💺')
console.log('encrypt', encryptedText)
console.log('decrypt', CryptoLib.decrypt(encryptedText, '💺'))
console.log('decrypt', CryptoLib.decrypt(encryptedText, '🚝'))
// caesar cypher OK
// var CaesarShifter = require('./libs/crypto-lib/caesar-shifter.js')
// console.log('encrypt', CaesarShifter.encrypt(chars, 0))
// console.log('encrypt', CaesarShifter.encrypt(chars, 1))
// console.log('encrypt', CaesarShifter.encrypt(chars, 2))
// console.log('encrypt', CaesarShifter.encrypt(chars, 3))
// console.log('encrypt', CaesarShifter.encrypt(chars, 4))
// console.log('encrypt', CaesarShifter.encrypt(chars, 10))
// console.log('decrypt', CaesarShifter.decrypt(CaesarShifter.encrypt(chars, 1), 1))
// console.log('decrypt', CaesarShifter.decrypt(CaesarShifter.encrypt(chars, 10), 10))
// emojifier
// var Emojifier = require('./libs/crypto-lib/emojifier.js')
// // Emojifier.generateEmojiListFrom()
// // console.log('0 ', Emojifier.encode(chars))
// // console.log('0 ', punycode.ucs2.encode(Emojifier.encode(chars)).length)
// Emojifier.generateEmojiListFrom(10)
// // console.log('20', Emojifier.encode(chars))
// // console.log('20', punycode.ucs2.encode(Emojifier.encode(chars)).length)
// gimmestats(Emojifier.encode(chars), 'encode')
// gimmestats2(Emojifier.decode(Emojifier.encode(chars)), 'decode')
// function gimmestats (text, name) {
// console.log(name, text, punycode.ucs2.decode(text).length)
// }
// function gimmestats2 (text, name) {
// console.log(name, text, text.length)
// }