Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | - | - | ||||
AeadExample.java | D | 04-Jul-2025 | 3.4 KiB | 92 | 50 | |
BUILD.bazel | D | 04-Jul-2025 | 1,013 | 34 | 29 | |
README.md | D | 04-Jul-2025 | 929 | 45 | 31 | |
aead_example_test.sh | D | 04-Jul-2025 | 4.8 KiB | 156 | 88 | |
aead_test_keyset.json | D | 04-Jul-2025 | 291 | 13 | 12 |
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