Class: Key

key~ Key

Class that represents an OpenPGP key. Must contain a primary key. Can contain additional subkeys, signatures, user ids, user attributes.

new Key(packetlist)

Parameters:
Name Type Description
packetlist packet.list The packets that form this key
Source:

Methods

armor() → {String}

Returns ASCII armored text of key
Source:
Returns:
ASCII armor
Type
String

decrypt(passphrase) → {Boolean}

Decrypts all secret key and subkey packets
Parameters:
Name Type Description
passphrase String
Source:
Returns:
true if all key and subkey packets decrypted successfully
Type
Boolean

decryptKeyPacket(keyIds, passphrase) → {Boolean}

Decrypts specific key packets by key ID
Parameters:
Name Type Description
keyIds Array.<keyid>
passphrase String
Source:
Returns:
true if all key packets decrypted successfully
Type
Boolean

getAllKeyPackets() → {Array.<(public_subkey|secret_subkey|packet_secret_key|packet_public_key)>}

Returns all the private and public key and subkey packets
Source:
Returns:
Type
Array.<(public_subkey|secret_subkey|packet_secret_key|packet_public_key)>

getEncryptionKeyPacket() → {public_subkey|secret_subkey|packet_secret_key|packet_public_key|null}

Returns the first valid encryption key packet for this key
Source:
Returns:
key packet or null if no encryption key has been found
Type
public_subkey | secret_subkey | packet_secret_key | packet_public_key | null

getKeyIds() → {Array.<keyid>}

Returns key IDs of all key packets
Source:
Returns:
Type
Array.<keyid>

getKeyPacket() → {packet_secret_key|packet_public_key|null}

Returns the primary key packet (secret or public)
Source:
Returns:
Type
packet_secret_key | packet_public_key | null

getPreferredSignatureHashAlgorithm() → {String}

Returns preferred signature hash algorithm of this key
Source:
Returns:
Type
String

getPrivateKeyPacket(keyIds) → {secret_subkey|packet_secret_key|null}

Returns first private key packet for given array of key IDs
Parameters:
Name Type Description
keyIds Array.<keyid>
Source:
Returns:
Type
secret_subkey | packet_secret_key | null

getPublicKeyPacket(keyIds) → {public_subkey|packet_public_key|null}

Returns first public key packet for given array of key IDs
Parameters:
Name Type Description
keyIds Array.<keyid>
Source:
Returns:
Type
public_subkey | packet_public_key | null

getSigningKeyPacket() → {public_subkey|secret_subkey|packet_secret_key|packet_public_key|null}

Returns first key packet that is available for signing
Source:
Returns:
Type
public_subkey | secret_subkey | packet_secret_key | packet_public_key | null

getSubkeyPackets() → {Array.<(public_subkey|secret_subkey)>}

Returns all the private and public subkey packets
Source:
Returns:
Type
Array.<(public_subkey|secret_subkey)>

getUserIds() → {Array.<string>}

Returns userids
Source:
Returns:
array of userids
Type
Array.<string>

isPrivate() → {Boolean}

Returns true if this is a private key
Source:
Returns:
Type
Boolean

isPublic() → {Boolean}

Returns true if this is a public key
Source:
Returns:
Type
Boolean

toPublic() → {Key}

Returns key as public key
Source:
Returns:
public key
Type
Key