Name Date Size #Lines LOC

..--

AeadExample.javaH A D25-Apr-20253.3 KiB9149

BUILD.bazelH A D25-Apr-2025930 3328

README.mdH A D25-Apr-2025929 4531

aead_example_test.shH A D25-Apr-20254.8 KiB15688

aead_test_keyset.jsonH A D25-Apr-2025291 1312

README.md

1# Java AEAD example
2
3This example shows how to encrypt data with Tink using Authenticated Encryption
4with Associated Data (AEAD).
5
6It demonstrates the basic steps of using Tink, namely loading key material,
7obtaining a primitive, and using the primitive to do crypto.
8
9The key material was generated with Tinkey:
10
11```shell
12tinkey create-keyset --key-template AES128_GCM --out-format JSON \
13    --out aead_test_keyset.json
14```
15
16## Build and run
17
18### Bazel
19
20```shell
21git clone https://github.com/google/tink
22cd tink/examples/java_src
23bazel build ...
24```
25
26Encrypt a file:
27
28```shell
29echo "some data" > testdata.txt
30
31./bazel-bin/aead/aead_example encrypt \
32    ./aead/aead_test_keyset.json \
33    testdata.txt testdata.txt.encrypted
34```
35
36Decrypt a file:
37
38```shell
39./bazel-bin/aead/aead_example decrypt \
40    ./aead/aead_test_keyset.json \
41    testdata.txt.encrypted testdata.txt.decrypted
42
43diff testdata.txt testdata.txt.decrypted
44```
45