@aws-amplify/auth
Version:
Auth category of aws-amplify
29 lines (28 loc) • 1.25 kB
TypeScript
import { AuthBigInteger } from './BigInteger';
/**
* Returns an unambiguous, even-length hex string of the two's complement encoding of an integer.
*
* It is compatible with the hex encoding of Java's BigInteger's toByteArray(), wich returns a
* byte array containing the two's-complement representation of a BigInteger. The array contains
* the minimum number of bytes required to represent the BigInteger, including at least one sign bit.
*
* Examples showing how ambiguity is avoided by left padding with:
* "00" (for positive values where the most-significant-bit is set)
* "FF" (for negative values where the most-significant-bit is set)
*
* padHex(bigInteger.fromInt(-236)) === "FF14"
* padHex(bigInteger.fromInt(20)) === "14"
*
* padHex(bigInteger.fromInt(-200)) === "FF38"
* padHex(bigInteger.fromInt(56)) === "38"
*
* padHex(bigInteger.fromInt(-20)) === "EC"
* padHex(bigInteger.fromInt(236)) === "00EC"
*
* padHex(bigInteger.fromInt(-56)) === "C8"
* padHex(bigInteger.fromInt(200)) === "00C8"
*
* @param {AuthBigInteger} bigInt Number to encode.
* @returns {String} even-length hex string of the two's complement encoding.
*/
export declare const getPaddedHex: (bigInt: AuthBigInteger) => string;