-
Notifications
You must be signed in to change notification settings - Fork 0
/
botan.mjs
33 lines (26 loc) · 1.11 KB
/
botan.mjs
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
//| Sciter-Botan 2.0+
//| https://github.com/MustafaHi/Sciter-Botan
import { loadLibrary } from "@sciter";
const Botan = globalThis.Botan || loadLibrary("sciter-botan");
export function password(method, data, hash = "") {
return new Promise((resolve, reject) => {
function CB(data, pass = true) { pass ? resolve(data) : reject(data); }
Botan.passwordN(CB, method, data, hash);
});
}
export function cipher(method, data, key, iv = "") {
return new Promise((resolve, reject) => {
function CB(data, pass = true) { pass ? resolve(data) : reject(data); }
Botan.cipherN(CB, method, data, key, iv);
});
}
export function decipher(method, data, key, iv) {
return new Promise((resolve, reject) => {
function CB(data, pass = true) { pass ? resolve(data) : reject(data); }
Botan.decipherN(CB, method, data, key, iv);
});
}
export function encode() { return Botan.encode(...arguments); }
export function decode() { return Botan.decode(...arguments); }
export function hash() { return Botan.hash(...arguments); }
export function iv() { return Botan.iv(...arguments); }