Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | - | - | ||||
BUILD.bazel | H A D | 25-Apr-2025 | 1.5 KiB | 71 | 62 | |
README.md | H A D | 25-Apr-2025 | 1 KiB | 43 | 31 | |
aead.py | H A D | 25-Apr-2025 | 2.6 KiB | 86 | 51 | |
aead_basic.py | H A D | 25-Apr-2025 | 2.5 KiB | 66 | 28 | |
aead_basic_test.py | H A D | 25-Apr-2025 | 803 | 27 | 8 | |
aead_test.sh | H A D | 25-Apr-2025 | 4.9 KiB | 175 | 98 | |
aead_test_keyset.json | H A D | 25-Apr-2025 | 291 | 13 | 12 |
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