lockbox.KeyFactory Class
Creates encryption keys.
Constructor
lockbox.KeyFactory
-
[ursa]
-
[fs]
Parameters:
-
[ursa]
Ursa optionalThe Ursa module to use.
-
[fs]
Fs optionalThe file system module to use.
Item Index
Methods
createPrivateKey
-
key
-
[password]
Create a new private key.
Throws:
- lockbox.exception.InvalidPrivateKeyException If the key is invalid.
Returns:
The private key.
createPrivateKeyFromFile
-
path
-
[password]
-
callback
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:
- lockbox.exception.ReadException If the file cannot be read.
- lockbox.exception.InvalidPrivateKeyException If the key is invalid.
createPrivateKeyFromFileSync
-
path
-
[password]
-
callback
Creates a new private key from a file synchronously.
Throws:
- lockbox.exception.ReadException If the file cannot be read.
- lockbox.exception.InvalidPrivateKeyException If the key is invalid.
Parameters:
Returns:
The private key.
createPublicKey
-
key
Parameters:
-
key
StringThe PEM formatted public key.
Returns:
The public key.
createPublicKeyFromFile
-
path
-
[password]
-
callback
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:
- lockbox.exception.ReadException If the file cannot be read.
- lockbox.exception.InvalidPublicKeyException If the key is invalid.
createPublicKeyFromFileSync
-
path
-
[password]
-
callback
Creates a new public key from a file synchronously.
Throws:
- lockbox.exception.ReadException If the file cannot be read.
- lockbox.exception.InvalidPublicKeyException If the key is invalid.
Parameters:
Returns:
The public key.
generatePrivateKey
-
[size]
Encrypt a data packet.
Parameters:
-
[size]
Number optionalThe key size in bits.
Returns:
The generated key.