Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Convert

Hierarchy

  • Convert

Index

Constructors

constructor

Methods

Static decodeHex

  • decodeHex(hex: string): string

Static hexToUint8

  • hexToUint8(input: string): Uint8Array
  • Converts a hex string to a uint8 array.

    Parameters

    • input: string

      A hex encoded string.

    Returns Uint8Array

    A uint8 array corresponding to the input.

Static hexToUint8Reverse

  • hexToUint8Reverse(input: string): Uint8Array
  • Reversed convertion hex string to a uint8 array.

    Parameters

    • input: string

      A hex encoded string.

    Returns Uint8Array

    A uint8 array corresponding to the input.

Static int8ToUint8

  • int8ToUint8(input: number): number
  • Converts a signed byte to an unsigned byte with the same binary representation.

    Parameters

    • input: number

      A signed byte.

    Returns number

    An unsigned byte with the same binary representation as the input.

Static isHexString

  • isHexString(input: string, expectedSize?: number): boolean
  • Determines whether or not a string is a hex string.

    Parameters

    • input: string

      The string to test.

    • expectedSize: number = 0

      the expected size of the input

    Returns boolean

    true if the input is a hex string, false otherwise.

Static numberToUint8Array

  • numberToUint8Array(number: number, arraySize: number): Uint8Array
  • It splits the number's bytes into a an array.

    Parameters

    • number: number

      the number

    • arraySize: number

      the expected size of the array.

    Returns Uint8Array

Static rstr2utf8

  • rstr2utf8(input: string): string
  • Converts a raw javascript string into a string of single byte characters using utf8 encoding. This makes it easier to perform other encoding operations on the string.

    Parameters

    • input: string

      A raw string

    Returns string

    • UTF-8 string

Static toByte

  • toByte(char1: string, char2: string): number
  • Decodes two hex characters into a byte.

    Parameters

    • char1: string

      The first hex digit.

    • char2: string

      The second hex digit.

    Returns number

    The decoded byte.

Static uint32ToUint8

  • uint32ToUint8(input: Uint32Array): Uint8Array
  • Converts a uint32 array to a uint8 array.

    Parameters

    • input: Uint32Array

      A uint32 array.

    Returns Uint8Array

    A uint8 array created from the input.

Static uint8ToHex

  • uint8ToHex(input: any): string
  • Converts a uint8 array to a hex string.

    Parameters

    • input: any

      A uint8 array.

    Returns string

    A hex encoded string corresponding to the input.

Static uint8ToInt8

  • uint8ToInt8(input: number): number
  • Converts an unsigned byte to a signed byte with the same binary representation.

    Parameters

    • input: number

      An unsigned byte.

    Returns number

    A signed byte with the same binary representation as the input.

Static uint8ToUint32

  • uint8ToUint32(input: any): Uint32Array
  • Converts a uint8 array to a uint32 array.

    Parameters

    • input: any

      A uint8 array.

    Returns Uint32Array

    A uint32 array created from the input.

Static uint8ToUtf8

  • uint8ToUtf8(input: Uint8Array): string
  • Convert Uint8Array to string with UTF-8 encoding

    Parameters

    • input: Uint8Array

      An UTF-8 string

    Returns string

Static uintArray8ToNumber

  • uintArray8ToNumber(array: Uint8Array): number
  • It creates a number from the bytes in the array.

    Parameters

    • array: Uint8Array

      the number from the bytes.

    Returns number

Static utf8ToHex

  • utf8ToHex(input: string): string

Static utf8ToUint8

  • utf8ToUint8(input: string): Uint8Array
  • Convert UTF-8 string to Uint8Array

    Parameters

    • input: string

      An string with UTF-8 encoding

    Returns Uint8Array

Static validateHexString

  • validateHexString(input: string, expectedSize: number, message: string): void
  • Validates if a string is a valid hex of the expected size.

    Parameters

    • input: string

      The string to test.

    • expectedSize: number

      the expected size of the input

    • message: string

      error message.

    Returns void

Static xor

  • xor(value1: Uint8Array, value2: Uint8Array): string
  • Generate xor for two byte arrays and return in hex string

    Parameters

    • value1: Uint8Array

      Value 1 bytes

    • value2: Uint8Array

      Value 2 bytes

    Returns string

    • delta value in Hex

Generated using TypeDoc