• Home
Name Date Size #Lines LOC

..--

BUILD.bazelD04-Jul-20251.1 KiB3631

README.mdD04-Jul-20251 KiB4431

StreamingAeadExample.javaD04-Jul-20255.5 KiB150105

streaming_aead_example_test.shD04-Jul-20254.3 KiB14281

streaming_aead_test_keyset.jsonD04-Jul-2025262 21

README.md

1# Java Streaming AEAD example
2
3This example shows how to encrypt files with Tink using Streaming Authenticated
4Encryption with Associated Data (Streaming 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_HKDF_4KB --out-format JSON \
13    --out streaming_aead_test_keyset.json
14```
15
16## Build and Run
17
18### Bazel
19
20```shell
21git clone https://github.com/tink-crypto/tink-java
22cd examples
23bazel build ...
24```
25
26Encrypt a file:
27
28```shell
29echo "some data" > testdata.txt
30./bazel-bin/streamingaead/streamingaead_example encrypt \
31    ./streamingaead/streaming_aead_test_keyset.json \
32    testdata.txt testdata.txt.encrypted
33```
34
35Decrypt a file:
36
37```shell
38./bazel-bin/streamingaead/streamingaead_example decrypt \
39    ./streamingaead/streaming_aead_test_keyset.json \
40    testdata.txt.encrypted testdata.txt.decrypted
41
42diff testdata.txt testdata.txt.decrypted
43```
44