tree: 48e3d2bdfcabfb9d6a00c844175ef9ab6601eaaf [path history] [tgz]
  1. aead_example_test.sh
  2. aead_test_keyset.json
  3. AeadExample.java
  4. BUILD
  5. README.md
examples/java_src/aead/README.md

Java AEAD example

This example shows how to encrypt data with Tink using Authenticated Encryption with Associated Data (AEAD).

It demonstrates the basic steps of using Tink, namely loading key material, obtaining a primitive, and using the primitive to do crypto.

The key material was generated with Tinkey:

tinkey create-keyset --key-template AES128_GCM --out-format JSON \
    --out aead_test_keyset.json

Build and run

Bazel

git clone https://github.com/google/tink
cd tink/examples/java_src
bazel build ...

You can then encrypt a file:

echo "some data" > testdata.txt
./bazel-bin/aead/aead_example encrypt testdata.txt testdata.txt.encrypted

or decrypt the file:

./bazel-bin/aead/aead_example decrypt testdata.txt.encrypted testdata.txt.decrypted
$ diff testdata.txt testdata.txt.decrypted