import sodium , { Uint8ArrayOutputFormat } from 'libsodium-wrappers-sumo' ; export async function equals ( a , b ) { await sodium . ready ; if ( a . constructor !== Uint8Array || b . constructor !== Uint8Array ) { return false ; } if ( a . length !== b . length ) { return false ; } return 0 === sodium . compare ( a , b ) ; } export async function to_base64 ( d ) { await sodium . ready ; return sodium . to_base64 ( d , sodium . base64_variants . ORIGINAL ) ; } export function from_base64 ( s ) { return new Uint8Array ( atob ( s ) . split ( '' ) . map ( ( c ) => c . charCodeAt ( 0 ) ) ) ; } export async function to_base64_url ( d ) { await sodium . ready ; return sodium . to_base64 ( d , sodium . base64_variants . URLSAFE ) ; } export async function from_base64_url ( s ) { await sodium . ready ; return sodium . from_base64 ( s , sodium . base64_variants . URLSAFE ) ; } export async function to_base64_url_nopad ( d ) { await sodium . ready ; return sodium . to_base64 ( d , sodium . base64_variants . URLSAFE_NO_PADDING ) ; } export async function from_base64_url_nopad ( s ) { await sodium . ready ; return sodium . from_base64 ( s , sodium . base64_variants . URLSAFE_NO_PADDING ) ; } export async function crypto_hash_sha256 ( d ) { await sodium . ready ; return sodium . crypto_hash_sha256 ( d ) ; } export async function randombytes_buf ( length ) { await sodium . ready ; return sodium . randombytes_buf ( length ) ; } export async function crypto_box_keypair ( ) { await sodium . ready ; return sodium . crypto_box_keypair ( 'uint8array' ) ; } export async function crypto_box_seal_open ( ciphertext , publicKey , privateKey , outputFormat ? ) { await sodium . ready ; return sodium . crypto_box_seal_open ( ciphertext , publicKey , privateKey , outputFormat ) ; } export async function crypto_box_open_easy ( ciphertext , nonce , publicKey , privateKey , outputFormat ? ) { await sodium . ready ; return sodium . crypto_box_open_easy ( ciphertext , nonce , publicKey , privateKey , outputFormat ) ; } export async function crypto_box_easy ( message , nonce , publicKey , privateKey , outputFormat ? ) { await sodium . ready ; return sodium . crypto_box_easy ( message , nonce , publicKey , privateKey , outputFormat ) ; }