Name Date Size #Lines LOC

..--

BUILD.bazelH A D25-Apr-20251.7 KiB7262

README.mdH A D25-Apr-20251.2 KiB4331

deterministic_aead.pyH A D25-Apr-20252.7 KiB8853

deterministic_aead_basic.pyH A D25-Apr-20252.7 KiB6728

deterministic_aead_basic_test.pyH A D25-Apr-2025858 278

deterministic_aead_test.shH A D25-Apr-20255.5 KiB192109

deterministic_aead_test_keyset.jsonH A D25-Apr-2025302 21

README.md

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