Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | - | - | ||||
BUILD.bazel | H A D | 25-Apr-2025 | 1.3 KiB | 54 | 47 | |
README.md | H A D | 25-Apr-2025 | 1.2 KiB | 49 | 34 | |
streaming_aead.py | H A D | 25-Apr-2025 | 5.4 KiB | 162 | 111 | |
streaming_aead_keyset.json | H A D | 25-Apr-2025 | 405 | 14 | 13 | |
streaming_aead_test.sh | H A D | 25-Apr-2025 | 3.8 KiB | 145 | 83 |
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