You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Gurpreet Paul edited this page Nov 18, 2022
·
3 revisions
Why Lazysodium?
The problem with current cryptography libraries is that they can be one of 4 things: difficult to use, poorly documented, out of date or poorly architected.
So we built Lazysodium to make it absolutely effortless to get started with cryptography. We picked Libsodium1.0.18 as our underlying C library. Libsodium is an immensely powerful, well-tested and well-audited cryptography library that we found was perfect for securing all types of things.
A small example
Compare the two ways you could use Lazysodium:
1. Using native functions
The following shows how to create a subkey from a master key. The subkey can then be used to encrypt and decrypt text.
byte[] subkey = subkey[32];
byte[] context = "Examples".getBytes(StandardCharsets.UTF_8);
byte[] masterKey = "a_master_key_of_length_32_bytes!".getBytes(StandardCharsets.UTF_8);
intresult = lazySodium.cryptoKdfDeriveFromKey(subkey, subkey.length, 1L, context, masterKey);
// Now check the resultif (res == 0) {
// We have a positive result. Let's store it in a database.StringsubkeyString = newString(subkey, StandardCharsets.UTF_8);
}
2. Or use Lazysodium's lazy functions
You could use the above native functions or you could use the "Lazy" functions 😄