API Docs for: 0.2.0
Show:

lockbox.KeyFactory Class

Creates encryption keys.

Constructor

lockbox.KeyFactory

(
  • [ursa]
  • [fs]
)

Parameters:

  • [ursa] Ursa optional

    The Ursa module to use.

  • [fs] Fs optional

    The file system module to use.

Methods

createPrivateKey

(
  • key
  • [password]
)
ursa.PrivateKey

Create a new private key.

Throws:

Parameters:

  • key String

    The PEM formatted private key.

  • [password] String optional

    The key password.

Returns:

ursa.PrivateKey:

The private key.

createPrivateKeyFromFile

(
  • path
  • [password]
  • callback
)
async

Creates a new private key from a file asynchronously.

If successful, the second argument to the callback will be an instance of ursa.PrivateKey. Otherwise, any errors will be returned as the first argument to the callback.

Possible errors:

Parameters:

  • path String

    The path to the PEM formatted private key.

  • [password] String optional

    The key password.

  • callback Function

    The callback function.

createPrivateKeyFromFileSync

(
  • path
  • [password]
  • callback
)
ursa.PrivateKey

Creates a new private key from a file synchronously.

Throws:

Parameters:

  • path String

    The path to the PEM formatted private key.

  • [password] String optional

    The key password.

  • callback Function

    The callback function.

Returns:

ursa.PrivateKey:

The private key.

createPublicKey

(
  • key
)
ursa.PublicKey

Create a new public key.

Throws:

Parameters:

  • key String

    The PEM formatted public key.

Returns:

ursa.PublicKey:

The public key.

createPublicKeyFromFile

(
  • path
  • [password]
  • callback
)
async

Creates a new public key from a file asynchronously.

If successful, the second argument to the callback will be an instance of ursa.PublicKey. Otherwise, any errors will be returned as the first argument to the callback.

Possible errors:

Parameters:

  • path String

    The path to the PEM formatted public key.

  • [password] String optional

    The key password.

  • callback Function

    The callback function.

createPublicKeyFromFileSync

(
  • path
  • [password]
  • callback
)
ursa.PublicKey

Creates a new public key from a file synchronously.

Throws:

Parameters:

  • path String

    The path to the PEM formatted public key.

  • [password] String optional

    The key password.

  • callback Function

    The callback function.

Returns:

ursa.PublicKey:

The public key.

generatePrivateKey

(
  • [size]
)
ursa.PrivateKey

Encrypt a data packet.

Parameters:

  • [size] Number optional

    The key size in bits.

Returns:

ursa.PrivateKey:

The generated key.