# Module: packet/public_key_encrypted_session_key

## packet/public_key_encrypted_session_key

#### new require("packet/public_key_encrypted_session_key")()

  Source:
    - packet/public_key_encrypted_session_key.js, line 43

Source:
  - packet/public_key_encrypted_session_key.js, line 18

### Members

#### encrypted :Array.<module:type/mpi>

  ##### Type:

  - Array.<module:type/mpi>
  Source:
    - packet/public_key_encrypted_session_key.js, line 53

### Methods

#### decrypt(key) → {String}

  Decrypts the session key (only for public key encrypted session key packets (tag 1)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `key` | module:packet/secret_key | Private key with secMPIs unlocked

  Source:
    - packet/public_key_encrypted_session_key.js, line 154

  ##### Returns:

  The unencrypted session key
  Type
    String

#### read(input, position, len) → {module:packet/public_key_encrypted_session_key}

  Parsing function for a publickey encrypted session key packet (tag 1).

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `input` | String | Payload of a tag 1 packet
  `position` | Integer | Position to start reading from the input string
  `len` | Integer | Length of the packet or the remaining length of input at position

  Source:
    - packet/public_key_encrypted_session_key.js, line 64

  ##### Returns:

  Object representation
  Type
    module:packet/public_key_encrypted_session_key

#### write(publicKeyId, publicMPIs, pubalgo, symmalgo, sessionkey) → {String}

  Create a string representation of a tag 1 packet

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `publicKeyId` | String | The public key id corresponding to publicMPIs key as string
  `publicMPIs` | Array.<module:type/mpi> | Multiprecision integer objects describing the public key
  `pubalgo` | Integer | The corresponding public key algorithm // See RFC4880 9.1
  `symmalgo` | Integer | The symmetric cipher algorithm used to encrypt the data within an encrypteddatapacket or encryptedintegrity- protecteddatapacket following this packet //See RFC4880 9.2
  `sessionkey` | String | A string of randombytes representing the session key

  Source:
    - packet/public_key_encrypted_session_key.js, line 113

  ##### Returns:

  The string representation
  Type
    String