-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JavaScript API is modularized
- Loading branch information
Showing
1 changed file
with
12 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); } |