ntc-jcrypto

ntc-jcrypto is module java cryptography

License

License

GroupId

GroupId

com.streetcodevn
ArtifactId

ArtifactId

ntc-jcrypto
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

ntc-jcrypto
ntc-jcrypto is module java cryptography
Project URL

Project URL

https://github.com/congnghia0609/ntc-jcrypto
Source Code Management

Source Code Management

https://github.com/congnghia0609/ntc-jcrypto/tree/master

Download ntc-jcrypto

How to add to project

<!-- https://jarcasting.com/artifacts/com.streetcodevn/ntc-jcrypto/ -->
<dependency>
    <groupId>com.streetcodevn</groupId>
    <artifactId>ntc-jcrypto</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.streetcodevn/ntc-jcrypto/
implementation 'com.streetcodevn:ntc-jcrypto:1.0.2'
// https://jarcasting.com/artifacts/com.streetcodevn/ntc-jcrypto/
implementation ("com.streetcodevn:ntc-jcrypto:1.0.2")
'com.streetcodevn:ntc-jcrypto:jar:1.0.2'
<dependency org="com.streetcodevn" name="ntc-jcrypto" rev="1.0.2">
  <artifact name="ntc-jcrypto" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.streetcodevn', module='ntc-jcrypto', version='1.0.2')
)
libraryDependencies += "com.streetcodevn" % "ntc-jcrypto" % "1.0.2"
[com.streetcodevn/ntc-jcrypto "1.0.2"]

Dependencies

compile (3)

Group / Artifact Type Version
ch.qos.logback : logback-classic jar 1.2.3
ch.qos.logback : logback-core jar 1.2.3
org.slf4j : slf4j-api jar 1.7.30

test (1)

Group / Artifact Type Version
junit : junit jar 4.13

Project Modules

There are no modules declared in this project.

ntc-jcrypto

ntc-jcrypto is module java cryptography

Maven

<dependency>
    <groupId>com.streetcodevn</groupId>
    <artifactId>ntc-jcrypto</artifactId>
    <version>1.0.2</version>
</dependency>

1. An implementation of Shamir's Secret Sharing Algorithm 256-bits in Java

Usage

Use encode/decode Base64

String s = "nghiatcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
SSS sss = new SSS();
List<String> arr = sss.create(3, 6, s, true);
//System.out.println(arr);
for (int i=0; i<arr.size(); i++) {
    System.out.println("shares["+i+"]: " + arr.get(i));
}

System.out.println("\nsecret: " + s);
System.out.println("secret.length: " + s.length());

String s1 = sss.combine(arr.subList(0, 3), true);
System.out.println("combines shares 1 length = " + arr.subList(0, 3).size());
System.out.println("secret: " + s1);
System.out.println("secret.length: " + s1.length());

String s2 = sss.combine(arr.subList(3, 6), true);
System.out.println("combines shares 2 length = " + arr.subList(3, 6).size());
System.out.println("secret: " + s2);
System.out.println("secret.length: " + s2.length());

String s3 = sss.combine(arr.subList(1, 5), true);
System.out.println("combines shares 3 length = " + arr.subList(1, 5).size());
System.out.println("secret: " + s3);
System.out.println("secret.length: " + s3.length());

Use encode/decode Hex

String s = "nghiatcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
SSS sss = new SSS();
List<String> arr = sss.create(3, 6, s, false);
//System.out.println(arr);
for (int i=0; i<arr.size(); i++) {
    System.out.println("shares["+i+"]: " + arr.get(i));
}

System.out.println("\nsecret: " + s);
System.out.println("secret.length: " + s.length());

String s1 = sss.combine(arr.subList(0, 3), false);
System.out.println("combines shares 1 length = " + arr.subList(0, 3).size());
System.out.println("secret: " + s1);
System.out.println("secret.length: " + s1.length());

String s2 = sss.combine(arr.subList(3, 6), false);
System.out.println("combines shares 2 length = " + arr.subList(3, 6).size());
System.out.println("secret: " + s2);
System.out.println("secret.length: " + s2.length());

String s3 = sss.combine(arr.subList(1, 5), false);
System.out.println("combines shares 3 length = " + arr.subList(1, 5).size());
System.out.println("secret: " + s3);
System.out.println("secret.length: " + s3.length());

License

This code is under the Apache License v2.

Versions

Version
1.0.2
1.0.1
1.0.0