Skip to content

Commit

Permalink
JS 2.0+
Browse files Browse the repository at this point in the history
JavaScript API is modularized
  • Loading branch information
MustafaHi committed Nov 3, 2021
1 parent 38e9c43 commit 4724d67
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions botan.mjs
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
//| Sciter-Botan 2.0
//| Sciter-Botan 2.0+
//| https://github.com/MustafaHi/Sciter-Botan

if (!globalThis.Botan)
{
import { loadLibrary } from "@sciter";
globalThis.Botan = loadLibrary("sciter-botan");
}
import { loadLibrary } from "@sciter";

const Botan = globalThis.Botan || loadLibrary("sciter-botan");


Botan.password = function(method, data, hash = "") {
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);
});
}

Botan.cipher = function(method, data, key, iv = "") {
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);
});
}

Botan.decipher = function(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); }

0 comments on commit 4724d67

Please sign in to comment.