Name Date Size #Lines LOC

..--

BUILD.bazelH A D25-Apr-20251.3 KiB5447

README.mdH A D25-Apr-20251.2 KiB4934

streaming_aead.pyH A D25-Apr-20255.4 KiB162111

streaming_aead_keyset.jsonH A D25-Apr-2025405 1413

streaming_aead_test.shH A D25-Apr-20253.8 KiB14583

README.md

1# Python streaming AEAD example
2
3This example shows how to encrypt files with Tink using streaming Authenticated
4Encryption with 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 using Tinkey:
10
11```shell
12$ tinkey create-keyset --key-template AES256_CTR_HMAC_SHA256_1MB \
13    --out-format JSON --out streaming_aead_keyset.json
14```
15
16## Build and run
17
18### Bazel
19
20Build the examples:
21
22```shell
23$ git clone https://github.com/google/tink
24$ cd tink/python/examples
25$ bazel build ...
26```
27
28You can then encrypt a file with:
29
30```shell
31$ echo "some data" > testdata.txt
32
33$ ./bazel-bin/streaming_aead/streaming_aead --mode encrypt \
34    --keyset_path ./streaming_aead/streaming_aead_keyset.json \
35    --input_path testdata.txt \
36    --output_path testdata.txt.ciphertext
37```
38
39And then decrypt the the output with:
40
41```shell
42$ ./bazel-bin/streaming_aead/streaming_aead --mode decrypt \
43    --keyset_path ./streaming_aead/streaming_aead_keyset.json \
44    --input_path testdata.txt.ciphertext \
45    --output_path testdata.txt.plaintext
46
47$ diff testdata.txt testdata.txt.decrypted
48```
49