Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | - | - | ||||
BUILD.bazel | H A D | 25-Apr-2025 | 1.7 KiB | 72 | 62 | |
README.md | H A D | 25-Apr-2025 | 1.2 KiB | 43 | 31 | |
deterministic_aead.py | H A D | 25-Apr-2025 | 2.7 KiB | 88 | 53 | |
deterministic_aead_basic.py | H A D | 25-Apr-2025 | 2.7 KiB | 67 | 28 | |
deterministic_aead_basic_test.py | H A D | 25-Apr-2025 | 858 | 27 | 8 | |
deterministic_aead_test.sh | H A D | 25-Apr-2025 | 5.5 KiB | 192 | 109 | |
deterministic_aead_test_keyset.json | H A D | 25-Apr-2025 | 302 | 2 | 1 |
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