keeferrourke / lazysodium-java

A Java implementation of the Libsodium crypto library. For the lazy dev.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lazysodium for Java

Lazysodium is a complete Java (JNA) wrapper over the Libsodium library that provides developers with a smooth and effortless cryptography experience.

Build Status Download

Why Lazysodium

We created Lazysodium because we really wanted a solid cryptography library that would just work without fuss.

We were exasperated and annoyed with current Libsodium implementations as some of them were just poorly maintained, poorly managed and, plain and simply, poorly architected.

Thus, Lazysodium was born with the blessings of Lazycode, a part of Terl that specialises in giving developers easy-to-use software and tools that just work. Read more about us below.

Here's what it's like to use native functions

byte[] subkey = subkey[32];
int subkeyLen = subkey.length;
long subkeyId = 1L;
byte[] context = "Examples".getBytes(StandardCharsets.UTF_8);
byte[] masterKey = "a_master_key".getBytes(StandardCharsets.UTF_8);
int result = lazySodium.cryptoKdfDeriveFromKey(subkey, subkeyLen, subkeyId, context, masterKey);

// Now check the result
if (res == 0) {
    // We have a positive result. Let's store it in a database.
    String subkeyString = new String(subkey, StandardCharsets.UTF_8);
}

Here's what it's like to use Lazysodium's lazy functions

You could use the above native functions or you could use the "Lazy" functions 😄

long subKeyId = 1L;
String context = "Examples";
String masterKey = "a_master_key";
String subkeyString = lazySodium.cryptoKdfDeriveFromKey(subKeyId, context, masterKey);

As you can see Lazysodium's lazy functions save you a lot of pain!


Get started

This section will help you get started with Lazysodium quickly (and with utmost laziness).

Requirements

Lazysodium for Java requires:

  • JDK 8 or higher.
  • Gradle 4.7 or higher (if compiling and building).
  • No effort whatsoever.

Add

If you didn't know already, all Java libraries are hosted on a central repository. Lazysodium is hosted on Bintray. This is important because you need to configure your build tool to pull and cache Lazysodium's packages from Bintray. The process is simple for Android projects... It's as simple as adding a few lines to your top-level build.gradle file.

allprojects {
    repositories {
        google()
        jcenter()
        
        // Add this line here!
        maven {
            url  "https://dl.bintray.com/terl/lazysodium-maven"
        }
    }
}

The process of adding a new repository is different depending on what build tool you use. A quick Google or DuckDuckGo search can help.

Now, after adding the above, all you have to do is tell your build tool what package/artifact to include. Substitute VERSION_NUMBER with the number provided in the following button:

Download

Gradle
dependencies {
    // ...
    implementation "com.goterl.lazycode:lazysodium-java:VERSION_NUMBER"
}
Maven
<dependency>
  <groupId>com.goterl.lazycode</groupId>
  <artifactId>lazysodium-java</artifactId>
  <version>VERSION_NUMBER</version>
  <type>pom</type>
</dependency>
Ivy
<dependency org='com.goterl.lazycode' name='lazysodium-java' rev=VERSION_NUMBER'>
  <artifact name='lazysodium-java' ext='pom' ></artifact>
</dependency>
SBT
libraryDependencies += "com.goterl.lazycode" % "lazysodium-java" % "VERSION_NUMBER"

Learn

For documentation, roadmap, compiling, usage, etc we invite you to head over to the wiki.

Contribute

Contributions are welcome! For more information please see the Contributor's Guide.



Created by the wizards at Terl.

About

A Java implementation of the Libsodium crypto library. For the lazy dev.

License:Mozilla Public License 2.0


Languages

Language:Java 100.0%