tree: eb549f69197ad1224415d8e3510fc6a06752d593 [path history] [tgz]
  1. BUILD.bazel
  2. README.md
  3. streaming_aead_example_test.sh
  4. streaming_aead_test_keyset.json
  5. StreamingAeadExample.java
java_src/examples/streamingaead/README.md

Java Streaming AEAD example

This example shows how to encrypt files with Tink using Streaming Authenticated Encryption with Associated Data (Streaming 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_HKDF_4KB --out-format JSON \
    --out streaming_aead_test_keyset.json

Build and Run

Bazel

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

Encrypt a file:

echo "some data" > testdata.txt
./bazel-bin/streamingaead/streamingaead_example encrypt \
    ./streamingaead/streaming_aead_test_keyset.json \
    testdata.txt testdata.txt.encrypted

Decrypt a file:

./bazel-bin/streamingaead/streamingaead_example decrypt \
    ./streamingaead/streaming_aead_test_keyset.json \
    testdata.txt.encrypted testdata.txt.decrypted

diff testdata.txt testdata.txt.decrypted