-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.js
137 lines (130 loc) · 3.48 KB
/
main.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import Vue from 'vue'
import App from './App.vue'
var CryptoJS = require("crypto-js");
import "@fontsource/montserrat/300.css";
Vue.config.productionTip = false
function ctoji(dec) { //map ascii printable characters to specific emoji faces
if (dec == 32) {
return (String.fromCodePoint(128169));
}
else if (dec == 33) {
return (String.fromCodePoint(129488));
}
else if (dec == 34) {
return (String.fromCodePoint(129402));
}
else if (dec == 35) {
return (String.fromCodePoint(129400));
}
else if (dec == 36) {
return (String.fromCodePoint(129303));
}
else if (dec <= 39) {
return (String.fromCodePoint(dec + 128547));
}
else if (dec <= 43) {
return (String.fromCodePoint(dec + 128537));
}
else if (dec <= 49) {
return (String.fromCodePoint(dec + 129252));
}
else if (dec <= 105) {
return (String.fromCodePoint(dec + 128462));
}
else if (dec <= 111) {
return (String.fromCodePoint(dec + 129206));
}
else if (dec <= 120) {
return (String.fromCodePoint(dec + 129207));
}
else {
return (String.fromCodePoint(dec + 129271));
}
}
function jitoc(dec) {
if (dec == 128169) {
return (String.fromCodePoint(32));
}
else if (dec == 129488) {
return (String.fromCodePoint(33));
}
else if (dec == 129402) {
return (String.fromCodePoint(34));
}
else if (dec == 129400) {
return (String.fromCodePoint(35));
}
else if (dec == 129303) {
return (String.fromCodePoint(36));
}
else if (dec >= 129392) {
return (String.fromCodePoint(dec - 129271));
}
else if (dec >= 129319) {
return (String.fromCodePoint(dec - 129207));
}
else if (dec >= 129312) {
return (String.fromCodePoint(dec - 129206));
}
else if (dec >= 129296) {
return (String.fromCodePoint(dec - 129252));
}
else if (dec >= 128584) {
return (String.fromCodePoint(dec - 128547));
}
else if (dec >= 128577) {
return (String.fromCodePoint(dec - 128537));
}
else {
return (String.fromCodePoint(dec - 128462));
}
}
var cryptoji = {
imessage: '',
xmessage: '',
omessage: '',
key: '',
xkey: '',
ocryptoji: '',
icryptoji: '',
xcryptoji: '',
navi:'encrypt',
encrypt: function() {
if (cryptoji.imessage != cryptoji.xmessage || cryptoji.key != cryptoji.xkey) {
cryptoji.xmessage = cryptoji.imessage;
cryptoji.xkey = cryptoji.key;
var cypher = CryptoJS.AES.encrypt(cryptoji.imessage, cryptoji.key).toString();
var sliced = cypher.slice(10);//remove U2FsdGVkX1
cryptoji.ocryptoji = '';
for (var i = 0; i < sliced.length; i++) {
var dec = sliced.codePointAt(i);
cryptoji.ocryptoji = cryptoji.ocryptoji + ctoji(dec);
}
}
},
decrypt: function() {
if (cryptoji.icryptoji != cryptoji.xcryptoji || cryptoji.key != cryptoji.xkey ) {
cryptoji.xcryptoji = cryptoji.icryptoji;
cryptoji.xkey = cryptoji.key;
cryptoji.icryptoji.replace(/[0-9]/g, '');
cryptoji.omessage = '';
var cypher = 'U2FsdGVkX1';
try {
//build cyphertext
for (var i = 0; i < cryptoji.icryptoji.length/2; i++) {
var dec = cryptoji.icryptoji.codePointAt(i * 2);
cypher = cypher + jitoc(dec);
}
//decrypt
var bytes = CryptoJS.AES.decrypt(cypher, cryptoji.key);
cryptoji.omessage = bytes.toString(CryptoJS.enc.Utf8);
} catch (error) {
cryptoji.omessage = '';
}
}
}
}
new Vue({
render: function (h) { return h(App) },
data: cryptoji
}).$mount('#app')