-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tis
18 lines (18 loc) · 815 Bytes
/
main.tis
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const hutton = include library "./target/release/hutton";
function self.ready() {
const w = self.intrinsicWidthMax();
const h = self.intrinsicHeight();
const (sw, sh) = view.screenBox(#frame, #dimension);
view.move((sw / 2) - (w / 2), (sh / 2) - (h / 2), w, h, true);
}
event click $(a) { Sciter.launch(this.@["href"]); return true; }
$([type=checkbox]) << event click { $(#crypt).text = this.state.checked ? "Decrypt" : "Encrypt"; }
function sanitize(string) { return string.replace(/[^a-z]/g, ""); }
$(#crypt) << event click {
const input = sanitize($(#input).value);
const password = sanitize($(#password).value);
const key = sanitize($(#key).value);
const decrypt = $(#decrypt).state.checked;
const ciphertext = hutton.encrypt(input, password, key, decrypt);
$(#output).value = ciphertext;
}