UNPKG

tink-crypto

Version:

A multi-language, cross-platform library that provides cryptographic APIs that are secure, easy to use correctly, and hard(er) to misuse.

85 lines (84 loc) 2.67 kB
/** * @license * Copyright 2020 Google LLC * SPDX-License-Identifier: Apache-2.0 */ /** * Does near constant time byte array comparison. * @param ba1 The first bytearray to check. * @param ba2 The second bytearray to check. * @return If the array are equal. */ export declare function isEqual(ba1: Uint8Array, ba2: Uint8Array): boolean; /** * Returns a new array that is the result of joining the arguments. */ export declare function concat(...var_args: Uint8Array[]): Uint8Array; /** * Converts a non-negative integer number to a 64-bit big-endian byte array. * @param value The number to convert. * @return The number as a big-endian byte array. * @throws {InvalidArgumentsException} * @static */ export declare function fromNumber(value: number): Uint8Array; /** * Converts the hex string to a byte array. * * @param hex the input * @return the byte array output * @throws {!InvalidArgumentsException} * @static */ export declare function fromHex(hex: string): Uint8Array; /** * Converts a byte array to hex. * * @param bytes the byte array input * @return hex the output * @static */ export declare function toHex(bytes: Uint8Array): string; /** * Converts the Base64 string to a byte array. * * @param encoded the base64 string * @param opt_webSafe True indicates we should use the alternative * alphabet, which does not require escaping for use in URLs. * @return the byte array output * @static */ export declare function fromBase64(encoded: string, opt_webSafe?: boolean): Uint8Array; /** * Base64 encode a byte array. * * @param bytes the byte array input * @param opt_webSafe True indicates we should use the alternative * alphabet, which does not require escaping for use in URLs. * @return base64 output * @static */ export declare function toBase64(bytes: Uint8Array, opt_webSafe?: boolean): string; /** * Converts a byte string to a byte array. Only support ASCII and Latin-1 * strings, does not support multi-byte characters. * * @param str the input * @return the byte array output * @static */ export declare function fromByteString(str: string): Uint8Array; /** * Turns a byte array into the string given by the concatenation of the * characters to which the numbers correspond. Each byte is corresponding to a * character. Does not support multi-byte characters. * * @param bytes Array of numbers representing * characters. * @return Stringification of the array. */ export declare function toByteString(bytes: Uint8Array): string; /** * Returns the element-wise XOR of two byte arrays of the same length */ export declare function xor(x: Uint8Array, y: Uint8Array): Uint8Array;