Giter Club home page Giter Club logo

nexus-java's Introduction

Nexus Keycode: Java (Beta)

This package allows you to encode Nexus Keycodes. This is a beta release.

Learn more about about Angaza Nexus here.

Installation

Source archives for each release are available in releases.

This package comes with a full suite of unit tests, which you can run in the normal way in your IDE.

Versioning

This package uses a form of semantic versioning. The version number is comprised of three components: MAJOR.MINOR.PATCH

Major version numbers represent breaking changes in the keycode protocol itself. This is the only version number that is relevant to keycodes themselves. For example, any keycode generated any version 1.X.Y of this encoder will be valid on any version 1.X.Y of the embedded decoder.

Minor version numbers represent breaking internal API changes. You may need to modify your code to accomodate these changes.

Patch version numbers represent changes that are fully backward compatible.

Usage

Generate keycodes for the full and small keypad protocols.

Full Protocol

Add Credit

byte[] secretKey = new HexToByteArray().convert("deadbeefdeadbeefdeadbeefdeadbeef");
int messageId = 42;
long seconds = 7 /* days */ * 24 /* hours */ * 60 /* minutes */ * 60 /* seconds */;
Date clampedTime = new Date();
KeycodeMetadata output = KeycodeFactory.addCredit(
        clampedTime,
        messageId,
        secretKey,
        KeycodeProtocol.FULL,
        seconds
);
String keycode = output.getKeycodeData().getKeycode();
// outputs *599 791 493 194 43#

Set Credit

int messageId = 43;
int hours = 14 /* days */ * 24 /* hours */;
FullMessage message = FullMessage.setCredit(messageId, hours, secretKey);
String keycode = message.toKeycode();
// outputs *272 511 292 039 01#

Unlock

int messageId = 44;
KeycodeMetadata output = KeycodeFactory.unlock(messageId, secretKey, KeycodeProtocol.FULL);
String keycode = output.getKeycodeData().getKeycode();
// outputs *578 396 697 305 45#

Small Protocol

Add Credit

int messageId = 31;
long seconds = 7 /* days */ * 24 /* hours */ * 60 /* minutes */ * 60 /* seconds */;
Date clampedTime = new Date();
KeycodeMetadata output = KeycodeFactory.addCredit(
        clampedTime,
        messageId,
        secretKey,
        KeycodeProtocol.SMALL,
        seconds
);
String keycode = output.getKeycodeData().getKeycode();
// outputs 154 535 324 353 534

Unlock

int messageId = 32;
KeycodeMetadata output = KeycodeFactory.unlock(messageId, secretKey, KeycodeProtocol.SMALL);
String keycode = output.getKeycodeData().getKeycode();
// outputs 153 233 555 553 342

nexus-java's People

Contributors

bsilverthorn avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.