Skip to content

Commit 9937296

Browse files
committed
2 parents 2a16a82 + 5b58e63 commit 9937296

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

README.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,31 @@ This library is still being developed. In meantime, please contact us at support
1010
## Example
1111
The following example is similar to what is covered in the [key verification tutorial](https://help.cryptolens.io/examples/key-verification). The only difference at this point is that the Java version does not have built in support for machine code computation.
1212

13+
Assuming you have referenced the `cryptolens.jar` file, the code below should generate successful result. A working project with the code below can be found in the [example-app](https://github.com/Cryptolens/cryptolens-java/tree/master/example-app) folder.
14+
1315
```java
16+
import io.cryptolens.Cryptolens;
17+
import io.cryptolens.LicenseKey;
18+
19+
public class Main {
20+
21+
public static void main(String[] args) {
22+
String RSAPubKey = "<RSAKeyValue><Modulus>khbyu3/vAEBHi339fTuo2nUaQgSTBj0jvpt5xnLTTF35FLkGI+5Z3wiKfnvQiCLf+5s4r8JB/Uic/i6/iNjPMILlFeE0N6XZ+2pkgwRkfMOcx6eoewypTPUoPpzuAINJxJRpHym3V6ZJZ1UfYvzRcQBD/lBeAYrvhpCwukQMkGushKsOS6U+d+2C9ZNeP+U+uwuv/xu8YBCBAgGb8YdNojcGzM4SbCtwvJ0fuOfmCWZvUoiumfE4x7rAhp1pa9OEbUe0a5HL+1v7+JLBgkNZ7Z2biiHaM6za7GjHCXU8rojatEQER+MpgDuQV3ZPx8RKRdiJgPnz9ApBHFYDHLDzDw==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";
1423

15-
public class App
16-
{
17-
public static void main(String[] argv) {
1824
Cryptolens cryptolens = Cryptolens.getDefault();
19-
cryptolens.setExponentBase64("AQAB");
20-
cryptolens.setModulusBase64("khbyu3/vAEBHi339fTuo2nUaQgSTBj0jvpt5xnLTTF35FLkGI+5Z3wiKfnvQiCLf+5s4r8JB/Uic/i6/iNjPMILlFeE0N6XZ+2pkgwRkfMOcx6eoewypTPUoPpzuAINJxJRpHym3V6ZJZ1UfYvzRcQBD/lBeAYrvhpCwukQMkGushKsOS6U+d+2C9ZNeP+U+uwuv/xu8YBCBAgGb8YdNojcGzM4SbCtwvJ0fuOfmCWZvUoiumfE4x7rAhp1pa9OEbUe0a5HL+1v7+JLBgkNZ7Z2biiHaM6za7GjHCXU8rojatEQER+MpgDuQV3ZPx8RKRdiJgPnz9ApBHFYDHLDzDw==");
25+
cryptolens.setRSAPubKey(RSAPubKey);
2126

22-
Cryptolens.ActivateResponse cryptolensResponse =
23-
cryptolens.activate( "WyI0NjUiLCJBWTBGTlQwZm9WV0FyVnZzMEV1Mm9LOHJmRDZ1SjF0Vk52WTU0VzB2Il0="
24-
, 3646
25-
, "MPDWY-PQAOW-FKSCH-SGAAU"
26-
, "289jf2afs3"
27-
);
27+
Cryptolens.ActivateResponse response =
28+
cryptolens.activate( "WyI0NjUiLCJBWTBGTlQwZm9WV0FyVnZzMEV1Mm9LOHJmRDZ1SjF0Vk52WTU0VzB2Il0="
29+
, 3646
30+
, "MPDWY-PQAOW-FKSCH-SGAAU"
31+
, "289jf2afs3"
32+
);
2833

29-
if (!cryptolensResponse.successful()) {
34+
if (!response.successful()) {
3035
System.out.println("Failed to activate!");
31-
Cryptolens.ActivateServerError er = cryptolensResponse.getServerError();
32-
Exception ex = cryptolensResponse.getException();
36+
Cryptolens.ActivateServerError er = response.getServerError();
37+
Exception ex = response.getException();
3338

3439
if (er != null) {
3540
System.out.println("Server error: " + er);
@@ -42,7 +47,7 @@ public class App
4247
return;
4348
}
4449

45-
LicenseKey licenseKey = cryptolensResponse.getLicenseKey();
50+
LicenseKey licenseKey = response.getLicenseKey();
4651

4752
System.out.println("Activation was successful!");
4853
System.out.println(licenseKey.getKey());

0 commit comments

Comments
 (0)