diff --git a/README.md b/README.md index ababe3c..bf69bb3 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@
This repository contains a few examples to quickly get you started with the waltid-identity code API. +
This repository contains a few examples to quickly get you started with the waltid-identity SDK.
@@ -30,22 +30,26 @@ For a selection of examples, please take a look at the following table: Follow the link to view the associated code example. -You can also view samples in the test directories of the [identity repository](https://github.com/walt-id/waltid-identity). +You can also view samples in the test directories of +the [identity repository](https://github.com/walt-id/waltid-identity). ## Running the examples We're writing our projects with Gradle in mind; however, you can absolutely also use Apache Maven. -Use the repository `https://maven.waltid.dev/releases`. For a web interface to list available artifacts and their current versions, +Use the repository `https://maven.waltid.dev/releases`. For a web interface to list available artifacts and their +current versions, visit https://maven.waltid.dev/#/releases/id/walt in your web browser. If you use Gradle with e.g., IntelliJ IDEA, you can simply run the examples by right-clicking them. ## Join the community -* Connect and get the latest updates: Discord | +* Connect and get the latest updates: + Discord | Newsletter | YouTube | Twitter -* Get help, request features and report bugs: GitHub +* Get help, request features and report bugs: + GitHub Discussions ## License diff --git a/settings.gradle.kts b/settings.gradle.kts index 37f15e2..b01c612 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1 +1 @@ -rootProject.name = "identity-test" +rootProject.name = "waltid-examples" diff --git a/src/main/java/waltid/CustomKeyExample.java b/src/main/java/waltid/CustomKeyExample.java index 4abcd7d..bd3d827 100644 --- a/src/main/java/waltid/CustomKeyExample.java +++ b/src/main/java/waltid/CustomKeyExample.java @@ -26,6 +26,23 @@ public CustomKeyExample(String xyz) { this._xyz = xyz; } + public static void runCustomKeyExample() { + var key = new CustomKeyExample("abc"); + System.out.println("A type: " + key.getKeyType()); + + var plaintext = "plaintext".getBytes(StandardCharsets.UTF_8); + System.out.println("Plaintext: " + new String(plaintext, StandardCharsets.UTF_8)); + + var signed = (byte[]) key.javaSignRaw(plaintext); + System.out.println("Stub signed: " + new String(signed, StandardCharsets.UTF_8)); + + var verify = key.javaVerifyRaw(signed, plaintext); + System.out.println("Stub verified: " + new String(verify, StandardCharsets.UTF_8)); + } + + public static void main(String[] args) { + runCustomKeyExample(); + } private byte[] reverseArray(byte[] arr) { for (int i = 0; i < arr.length / 2; i++) { @@ -94,7 +111,7 @@ public String javaSignJws(@NotNull byte[] plaintext, @NotNull Map