Getting Started
Please read the Introduction section if you haven't already.
Now that you have successfully installed Simpl.DB in your project, you will need to create a JSON file, which is where your data will be stored.
Setting up the Database
Requiring the package
Creating the Database
filePath
path must be absolute.
It's highly recommended that the saveOnUpdate
option is set to false
and that you manually save the changes with Database#save() if you are working with a large amount of data.
Encrypting and Decrypting data
Simpl.DB allows you to encrypt and decrypt data. This is useful to store important data such as passwords or secret tokens. Since both encrypting and decrypting take a few seconds, in order to keep the package as speedy as possible, only the Database#set() and Database#get() methods support encryption and decryption.
To enable these functionalities, you must have an Encryption Key (you can read more about it here if you want).
Please make sure that if you generate your Encryption Key through the website provided below, you only check the Include Numbers, Include Lowercase Characters, Include Uppercase Characters, Exclude Similar Characters and Generate On Your Device options and that you have the Password Length option set to 32.
It's highly recommended that the Encryption Key only includes numbers and uppercase and lowercase letters, since some special characters could break it.
Since Simpl.DB uses AES256-CTR to encrypt and decrypt data, your Encryption Key must be a combination of 32 random characters. To generate yours, visit this website or simply write it yourself.
Once you have your hands on a brand new Encryption Key, make sure you store it in a safe place, such as an environment variable in a .env
file or something similar.
Last updated