xref: /aosp_15_r20/external/tink/java_src/examples/deterministicaead/README.md (revision e7b1675dde1b92d52ec075b0a92829627f2c52a5)
1# Java Deterministic AEAD example
2
3This example shows how to encrypt files with Tink using Deterministic
4Authenticated Encryption with Associated Data (Deterministic 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 AES256_SIV --out-format JSON \
13    --out deterministic_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/deterministicaead/deterministic_aead_example encrypt \
32    ./deterministicaead/deterministic_aead_test_keyset.json \
33    testdata.txt testdata.txt.encrypted
34```
35
36Decrypt a file:
37
38```shell
39./bazel-bin/deterministicaead/deterministic_aead_example decrypt \
40    ./deterministicaead/deterministic_aead_test_keyset.json \
41    testdata.txt.encrypted testdata.txt.decrypted
42
43diff testdata.txt testdata.txt.decrypted
44```
45