If SelfGuard was instantiated with a key pair, it will automatically encrypt data such that only the owner of the key pair will be able to decrypt the data.

AES-256 Encryption

This allows you to encrypt/decrypt any piece of data. Encryption keys are stored with SelfGuard.

Encrypt (AES-256)

value
object | string
required

A string or object that you want encrypted.

await sg.encrypt(value);

Decrypt (AES-256)

value
object | string
required

A string or object that you want decrypted.

encryption_key_id
string
required

The id of the encryption key returned from sg.encrypt.

await sg.decrypt(value, encryption_key_id);

Password Encryption

This allows you to encrypt/decrypt any piece of data with a password. Nothing is stored with SelfGuard here.

Encrypt With Password

value
object | string
required

A string or object that you want encrypted.

password
password
required

The password you want to use to encrypt the value.

sg.encryptWithPassword(value,password);

Decrypt With Password

value
object | string
required

A string or object that you want decrypted.

password
string
required

The password you want to use to decrypt the value.

sg.decryptWithPassword(value, password);

Data Tokenization

This allows you to encrypt data and store the encrypted data with SelfGuard itself. Each piece of data encrypted will have a respective token id.

Tokenize

value
object | string
required

A string or object that you want tokenized.

await sg.tokenize(value);

Detokenize

token_id
string
required

The token id of the data previously tokenized using sg.tokenize

await sg.detokenize(token_id);

Encrypted Key/Value Storage

This allows you to store any key value data where the value is encrypted.

Put

key
string
required

The key with which you want to associate the value.

value
object | string
required

A string or object that you want encrypted.

await sg.put(key, value);

Get

key
string
required

The key with which you want to retrieve the value.

await sg.get(key);

Get All Keys

await sg.getKeys();