Home
Core Encryption
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)

valuerequired
object | string

A string or object that you want encrypted.

await sg.encrypt(value);

Decrypt (AES-256)

valuerequired
object | string

A string or object that you want decrypted.

encryption_key_idrequired
string

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

valuerequired
object | string

A string or object that you want encrypted.

passwordrequired
password

The password you want to use to encrypt the value.

sg.encryptWithPassword(value,password);

Decrypt With Password

valuerequired
object | string

A string or object that you want decrypted.

passwordrequired
string

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

valuerequired
object | string

A string or object that you want tokenized.

await sg.tokenize(value);

Detokenize

token_idrequired
string

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

keyrequired
string

The key with which you want to associate the value.

valuerequired
object | string

A string or object that you want encrypted.

await sg.put(key, value);

Get

keyrequired
string

The key with which you want to retrieve the value.

await sg.get(key);

Get All Keys

await sg.getKeys();