Name Date Size #Lines LOC

..--

BUILD.bazelH A D25-Apr-20251.5 KiB7162

README.mdH A D25-Apr-20251 KiB4331

aead.pyH A D25-Apr-20252.6 KiB8651

aead_basic.pyH A D25-Apr-20252.5 KiB6628

aead_basic_test.pyH A D25-Apr-2025803 278

aead_test.shH A D25-Apr-20254.9 KiB17598

aead_test_keyset.jsonH A D25-Apr-2025291 1312

README.md

1# Python AEAD example
2
3This example shows how to encrypt files 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
12$ tinkey 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
21$ git clone https://github.com/google/tink
22$ cd tink/python/examples
23$ bazel build ...
24```
25
26You can then encrypt a file with:
27
28```shell
29$ echo "some data" > testdata.txt
30$ ./bazel-bin/aead/aead --mode encrypt \
31    --keyset_path ./aead/aead_test_keyset.json \
32    --input_path testdata.txt --output_path testdata.txt.encrypted
33```
34
35and then decrypt the the output with:
36
37```shell
38$ ./bazel-bin/aead/aead --mode decrypt \
39    --keyset_path ./aead/aead_test_keyset.json \
40    --input_path testdata.txt.encrypted --output_path testdata.txt.decrypted
41$ diff testdata.txt testdata.txt.decrypted
42```
43