tree: 9deb4fcadca1dc81ffe46f4eabe46378d95a5430
  1. BUILD.bazel
  2. cleartext_keyset_example_test.sh
  3. CleartextKeysetExample.java
  4. README.md
examples/cleartextkeyset/README.md

Java cleartext keysets example

This example shows how to generate or load a cleartext keyset, obtain a primitive, and use the primitive to do crypto.

WARNING: This is not recommended, consider protecting your keysets with a key management system.

Build and run

Bazel

git clone https://github.com/tink-crypto/tink-java
cd examples
bazel build ...

Generate a cleartext keyset:

./bazel-bin/cleartextkeyset/cleartext_keyset_example generate aes128_gcm_test_keyset.json

Encrypt a file with the resulting keyset:

echo "some data" > testdata.txt
./bazel-bin/cleartextkeyset/cleartext_keyset_example encrypt \
    aes128_gcm_test_keyset.json \
    testdata.txt testdata.txt.encrypted

Decrypt the file with the resulting keyset:

./bazel-bin/cleartextkeyset/cleartext_keyset_example decrypt \
    aes128_gcm_test_keyset.json \
    testdata.txt.encrypted testdata.txt.decrypted

diff testdata.txt testdata.txt.decrypted