age-encryption / Encrypter
Defined in: index.ts:72
Encrypts a file using the given passphrase or recipients.
First, call Encrypter.setPassphrase to set a passphrase for symmetric encryption, or Encrypter.addRecipient to specify one or more recipients. Then, call Encrypter.encrypt one or more times to encrypt files using the configured passphrase or recipients.
new Encrypter():
Encrypter
addRecipient(
s
):void
Defined in: index.ts:118
Add a recipient to encrypt the file(s) for. This method can be called multiple times to encrypt the file(s) for multiple recipients.
The recipient to encrypt the file for. Either a string
beginning with age1...
or an object implementing the Recipient
interface.
string
| Recipient
void
encrypt(
file
):Promise
<Uint8Array
>
Defined in: index.ts:138
Encrypt a file using the configured passphrase or recipients.
The file to encrypt. If a string is passed, it will be encoded as UTF-8.
string
| Uint8Array
Promise
<Uint8Array
>
A promise that resolves to the encrypted file as a Uint8Array.
setPassphrase(
s
):void
Defined in: index.ts:89
Set the passphrase to encrypt the file(s) with. This method can only be called once, and can't be called if Encrypter.addRecipient has been called.
The passphrase is passed through the scrypt key derivation function, but it needs to have enough entropy to resist offline brute-force attacks. You should use at least 8-10 random alphanumeric characters, or 4-5 random words from a list of at least 2000 words.
string
The passphrase to encrypt the file with.
void
setScryptWorkFactor(
logN
):void
Defined in: index.ts:106
Set the scrypt work factor to use when encrypting the file(s) with a passphrase. The default is 18. Using a lower value will require stronger passphrases to resist offline brute-force attacks.
number
The base-2 logarithm of the scrypt work factor.
void