# Module: crypto/crypto

## crypto/crypto

Source:
  - crypto/crypto.js, line 20

### Methods

#### <static> generateSessionKey(algo) → {String}

  Generating a session key for the specified symmetric algorithm

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `algo` | Integer | Algorithm to use (see RFC4880 9.2)

  Source:
    - crypto/crypto.js, line 214

  ##### Returns:

  Random bytes as a string to be used as a key
  Type
    String

#### <static> getPrefixRandom(algo) → {String}

  generate random byte prefix as string for the specified algorithm

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `algo` | Integer | Algorithm to use (see RFC4880 9.2)

  Source:
    - crypto/crypto.js, line 205

  ##### Returns:

  Random bytes with length equal to the block size of the cipher
  Type
    String

#### <static> getPrivateMpiCount(algo) → {Integer}

  Returns the number of integers comprising the private key of an algorithm

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `algo` | String | The public key algorithm

  Source:
    - crypto/crypto.js, line 114

  ##### Returns:

  The number of integers.
  Type
    Integer

#### <static> publicKeyDecrypt(algo, publicMPIs, secretMPIs, data) → {module:type/mpi}

  Decrypts data using the specified public key multiprecision integers of the private key, the specified secretMPIs of the private key and the specified algorithm.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `algo` | Integer | Algorithm to be used (See RFC4880 9.1)
  `publicMPIs` | Array.<module:type/mpi> | Algorithm dependent multiprecision integers of the public key part of the private key
  `secretMPIs` | Array.<module:type/mpi> | Algorithm dependent multiprecision integers of the private key used
  `data` | module:type/mpi | Data to be encrypted as MPI

  Source:
    - crypto/crypto.js, line 80

  ##### Returns:

  returns a big integer containing the decrypted data; otherwise null
  Type
    module:type/mpi

#### <static> publicKeyEncrypt(algo, publicMPIs, data) → {Array.<module:type/mpi>}

  Encrypts data using the specified public key multiprecision integers and the specified algorithm.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `algo` | Integer | Algorithm to be used (See RFC4880 9.1)
  `publicMPIs` | Array.<module:type/mpi> | Algorithm dependent multiprecision integers
  `data` | module:type/mpi | Data to be encrypted as MPI

  Source:
    - crypto/crypto.js, line 37

  ##### Returns:

  if RSA an module:type/mpi; if elgamal encryption an array of two module:type/mpi is returned; otherwise null
  Type
    Array.<module:type/mpi>