Coder Social home page Coder Social logo

sarxos / secure-tokens Goto Github PK

View Code? Open in Web Editor NEW
80.0 19.0 47.0 160 KB

Small set of tools allowing you to create secure encrypted tokens, which can be later exchanged with 3rd party systems or stored as a license files. The goal of this project is to play with JCA and learn its API.

License: MIT License

Java 100.00%

secure-tokens's Introduction

Secure Tokens

Secure Tokens is a set of tools / classes / annotations allowing you to create secure encrypted tokens from any object, which can be later exchanged with 3 rd party systems or simply stored as license file.

Features

  1. Supports following ciphers:
    • AES
    • Blowfish
    • Camelia
    • DES
    • IDEA
    • Noekeon
    • NOOP (no-operation)
    • SEED
    • Serpent
    • Twofish
  2. Supports compression (long tokens are GZIP-compressed)
  3. Support machine Serial Number identification

Example

Below there are some secret information in Example class. We would like to encrypt them and send to some 3 rd party system along with some kind of request identification โ€“ in this case this will be computer serial number obtained from Hardware class.

Assume we have the following class:

public static class Example implements Token {
	/**
	 * Some kind of secret data.
	 */
	@TokenPart("id")
	protected int id = 4;
	/**
	 * Some other kind of secret data 2.
	 */
	@TokenPart("sec")
	protected String secret = "secret.information.is.here";
	/**
	 * Computer Serial Number
	 */
	@TokenPart("sn")
	protected String sn = Hardware.getSerialNumber();
}

And the main method:

public static void main(String[] args) {
	Example example = new Example();
	CipherType cipher = CipherType.AES;
	String password = "secret password";
	String token = Tokenizer.tokenize(example, cipher, password);
	System.out.println("token:  " + token);
	Example checkme = Tokenizer.objectify(Example.class, token, cipher, password);
	System.out.println("id:     " + checkme.id);
	System.out.println("secret: " + checkme.secret);
	System.out.println("sn:     " + checkme.sn);
}

The output will be:

token:  9bLvGViEM7zAG872nz9W3wHGIFfl0j14lfNoogwCkZn0i7bbOhz3xukYopBKxjAXR75ht/DeF29wxuFMO3kFQQ==
id:     4
secret: secret.information.is.here
sn:     CZC14057LY

Of course there is a possibility to not encrypt data if someone would like to create clear text token. This can be done by using CipherType.NOOP (no-operation) cipher:

public static void main(String[] args) {
	Example example = new Example();
	CipherType cipher = CipherType.NOOP;
	String password = "secret password";
	String token = Tokenizer.tokenize(example, cipher, password);
	System.out.println("token:  " + token);
}

This will print:

token:  id=4#sn=CZC14057LY#sec=secret.information.is.here

secure-tokens's People

Contributors

kulmann avatar sarxos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

secure-tokens's Issues

get Hardware Serial Number in Linux is not Work

Hi
i try to get the Hardware serial number in linux, i try your code but not work , can you help me to solve it.
java.io.IOException: Cannot run program "lshal": error=2, No such file or directory.
thanks

Using Hardware4*.java code in another project

I'm one of the developers on the Oshi project, providing cross-platform JNA-based hardware information.

A user has requested CPU serial number and I found this project after reading your reply to this StackOverflow post.

I'd love to just copy your Hardware4*.java files straight over to my project, with perhaps some minor modifications, but want to respect your licensing. Is it sufficient to include your name as author with our EPL license? Are there any other ways to get your files (releasing a jar, publishing on Maven central, etc.) without copying the source? Would you be interested in contributing a PR yourself?

Serial Number not found in Ubuntu

Hello,

First of all, thanks for creating such a awesome library. It helped me a lot in creating license validation library.

However, when I test the application on Ubuntu, It throws exception saying, Serial Number Not found. This is because I can not execute dmidecode without root permission.

Is there any work around that you can think of to work around without root permission.

Thanks again, I am also brainstorming about this, but if possible, let's find solution together!

Daksh

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.