# Class: Util

## module:util/util~ Util

Implementation of the util object

#### new Util()

  This object contains utility functions
  Source:
    - util/util.js, line 29

### Members

#### bin2str

  Convert an array of integers(0.255) to a string
  Source:
    - util/util.js, line 193

#### Uint8Array2str

  Convert a Uint8Array to a string. This currently functions the same as bin2str.
  Source:
    - util/util.js, line 210

### Methods

#### calc_checksum(text) → {Integer}

  Calculates a 16bit sum of a string by adding each character codes modulus 65535

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `text` | String | String to create a sum of

  Source:
    - util/util.js, line 219

  ##### Returns:

  An integer containing the sum of all character codes % 65535
  Type
    Integer

#### decode_utf8(utf8) → {String}

  Convert a string of utf8 bytes to a native javascript string

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `utf8` | String | A valid squence of utf8 bytes

  Source:
    - util/util.js, line 152

  ##### Returns:

  A native javascript string
  Type
    String

#### encode_utf8(str) → {String}

  Convert a native javascript string to a string of utf8 bytes

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `str` | String | The string to convert

  Source:
    - util/util.js, line 143

  ##### Returns:

  A valid squence of utf8 bytes
  Type
    String

#### get_hashAlgorithmString() → {String}

  Return the algorithm type as string
  Source:
    - util/util.js, line 292

  ##### Returns:

  String representing the message type
  Type
    String

#### hex2bin(str) → {String}

  Create binary string from a hex encoded string

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `str` | String | Hex string to convert

  Source:
    - util/util.js, line 112

  ##### Returns:

  String containing the binary values
  Type
    String

#### hexidump(str) → {String}

  Creating a hex string from an binary array of integers (0..255)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `str` | String | Array of bytes to convert

  Source:
    - util/util.js, line 124

  ##### Returns:

  Hexadecimal representation of the array
  Type
    String

#### hexstrdump(str) → {String}

  Create hexstring from a binary

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `str` | String | String to convert

  Source:
    - util/util.js, line 92

  ##### Returns:

  String containing the hexadecimal values
  Type
    String

#### print_debug(str)

  Helper function to print a debug message. Debug messages are only printed if openpgp.config.debug is set to true.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `str` | String | String of the debug message

  Source:
    - util/util.js, line 238

#### print_debug_hexstr_dump(str)

  Helper function to print a debug message. Debug messages are only printed if openpgp.config.debug is set to true. Different than print_debug because will call hexstrdump iff necessary.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `str` | String | String of the debug message

  Source:
    - util/util.js, line 251

#### shiftRight(value, bitcount) → {String}

  Shifting a string to n bits right

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `value` | String | The string to shift
  `bitcount` | Integer | Amount of bits to shift (MUST be smaller than 9)

  Source:
    - util/util.js, line 274

  ##### Returns:

  Resulting string.
  Type
    String

#### str2bin(str) → {Array.<Integer>}

  Convert a string to an array of integers(0.255)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `str` | String | String to convert

  Source:
    - util/util.js, line 183

  ##### Returns:

  An array of (binary) integers
  Type
    Array.<Integer>

#### str2Uint8Array(str) → {Uint8Array}

  Convert a string to a Uint8Array

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `str` | String | String to convert

  Source:
    - util/util.js, line 200

  ##### Returns:

  The array of (binary) integers
  Type
    Uint8Array