encryption
Functions
<dl> <dt><a href="#encrypt">encrypt(text)</a> ⇒ <code>string</code></dt> <dd><p>Encrypts a plaintext private key using AES-256-GCM. The derived key is obtained via scrypt from the environment variable WALLET_ENCRYPTION_KEY.</p> </dd> <dt><a href="#decrypt">decrypt(encryptedData)</a> ⇒ <code>string</code></dt> <dd><p>Decrypts an encrypted private key payload. Expected format is <code>iv:authTag:ciphertext</code> produced by the <code>encrypt</code> function. If the payload is unencrypted (legacy format), it returns the payload as-is.</p> </dd> <dt><a href="#isEncrypted">isEncrypted(data)</a> ⇒ <code>boolean</code></dt> <dd><p>Checks if a string contains an encrypted payload matching the expected AES-256-GCM hex-encoded format.</p> </dd> </dl>
<a name="encrypt"></a>
encrypt(text) ⇒ <code>string</code>
Encrypts a plaintext private key using AES-256-GCM. The derived key is obtained via scrypt from the environment variable WALLET_ENCRYPTION_KEY.
Kind: global function
Returns: <code>string</code> - The encrypted payload in the format iv:authTag:ciphertext (all hex encoded).
| Param | Type | Description |
|---|---|---|
| text | <code>string</code> | The plaintext private key to encrypt. |
<a name="decrypt"></a>
decrypt(encryptedData) ⇒ <code>string</code>
Decrypts an encrypted private key payload.
Expected format is iv:authTag:ciphertext produced by the encrypt function.
If the payload is unencrypted (legacy format), it returns the payload as-is.
Kind: global function
Returns: <code>string</code> - The plaintext private key.
| Param | Type | Description |
|---|---|---|
| encryptedData | <code>string</code> | The encrypted payload to decrypt. |
<a name="isEncrypted"></a>
isEncrypted(data) ⇒ <code>boolean</code>
Checks if a string contains an encrypted payload matching the expected AES-256-GCM hex-encoded format.
Kind: global function
Returns: <code>boolean</code> - True if the format indicates the payload is encrypted.
| Param | Type | Description |
|---|---|---|
| data | <code>string</code> | The string payload to check. |