This package allows you to encode Nexus Keycodes. This is a beta release.
Learn more about about Angaza Nexus here.
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.
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.
Generate keycodes for the full and small keypad protocols.
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#
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