Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | - | - | ||||
BUILD.bazel | H A D | 25-Apr-2025 | 681 | 31 | 26 | |
README.md | H A D | 25-Apr-2025 | 1.1 KiB | 44 | 31 | |
cleartext_keyset.py | H A D | 25-Apr-2025 | 3.2 KiB | 103 | 61 | |
cleartext_keyset_test.sh | H A D | 25-Apr-2025 | 2.8 KiB | 98 | 46 |
README.md
1# Python example: working with cleartext keysets 2 3This example shows how to generate or load a cleartext keyset, obtain a 4primitive, and use the primitive to do crypto. 5 6WARNING: this is not recommended, consider protecting your keysets with a key 7management system. 8 9## Build and run 10 11### Bazel 12 13```shell 14$ git clone https://github.com/google/tink 15$ cd tink/python/examples 16$ bazel build ... 17``` 18 19You can generate a cleartext keyset: 20 21```shell 22$ ./bazel-bin/cleartext_keyset/cleartext_keyset --mode generate \ 23 --keyset_path aes128_gcm_test_keyset.json 24``` 25 26You can then encrypt a file with the resulting keyset: 27 28```shell 29$ echo "some data" > testdata.txt 30$ ./bazel-bin/cleartext_keyset/cleartext_keyset --mode encrypt \ 31 --keyset_path aes128_gcm_test_keyset.json \ 32 --input_path testdata.txt --output_path testdata.txt.encrypted 33``` 34 35Or decrypt a file with: 36 37```shell 38$ ./bazel-bin/cleartext_keyset/cleartext_keyset --mode decrypt \ 39 --keyset_path aes128_gcm_test_keyset.json \ 40 --input_path testdata.txt.encrypted --output_path testdata.txt.decrypted 41 42$ diff testdata.txt testdata.txt.decrypted 43``` 44