# Module: packet/secret_key

## packet/secret_key

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

  Source:
    - packet/secret_key.js, line 37

Source:
  - packet/secret_key.js, line 18

### Members

#### algorithm :openpgp.publickey :openpgp.publickey

  Public key algorithm

  ##### Type:

  - openpgp.publickey
  Inherited From:
    - module:packet/public_key#algorithm
  Source:
    - packet/public_key.js, line 45

#### created :Date :Date

  Key creation date.

  ##### Type:

  - Date
  Inherited From:
    - module:packet/public_key#created
  Source:
    - packet/public_key.js, line 39

#### mpi :module:type/mpi :module:type/mpi

  A list of multiprecision integers

  ##### Type:

  - module:type/mpi
  Inherited From:
    - module:packet/public_key#mpi
  Source:
    - packet/public_key.js, line 42

#### readPublicKey

  Internal Parser for public keys as specified in RFC 4880 section 5.5.2 Public-Key Packet Formats called by read_tag<num>
  Inherited From:
    - module:packet/public_key#readPublicKey
  Source:
    - packet/public_key.js, line 59

### Methods

#### decrypt(str_passphrase) → {Boolean}

  Decrypts the private key MPIs which are needed to use the key. openpgp_packet_keymaterial.hasUnencryptedSecretKeyData should be false otherwise a call to this function is not needed

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `str_passphrase` | String | The passphrase for this private key as string

  Source:
    - packet/secret_key.js, line 197

  ##### Returns:

  True if the passphrase was correct or MPI already decrypted; false if not
  Type
    Boolean

#### encrypt(passphrase)

  Encrypt the payload. By default, we use aes256 and iterated, salted string to key specifier

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `passphrase` | String |

  Source:
    - packet/secret_key.js, line 162

#### getFingerprint() → {String}() → {String}

  Calculates the fingerprint of the key
  Inherited From:
    - module:packet/public_key#getFingerprint
  Source:
    - packet/public_key.js, line 157

  ##### Returns:

  A string containing the fingerprint
  Type
    String

#### getKeyId() → {String}() → {String}

  Calculates the key id of the key
  Inherited From:
    - module:packet/public_key#getKeyId
  Source:
    - packet/public_key.js, line 143

  ##### Returns:

  A 8 byte key id
  Type
    String

#### read(bytes)

  Internal parser for private keys as specified in RFC 4880 section 5.5.3

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `bytes` | String | Input string to read the packet from

  Source:
    - packet/secret_key.js, line 109

#### write() → {String}

  Creates an OpenPGP key packet for the given key.
  Source:
    - packet/secret_key.js, line 141

  ##### Returns:

  A string of bytes containing the secret key OpenPGP packet
  Type
    String