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 | 948 | 45 | 32 | |
mac.py | H A D | 25-Apr-2025 | 2.8 KiB | 95 | 59 | |
mac_basic.py | H A D | 25-Apr-2025 | 2.5 KiB | 66 | 28 | |
mac_basic_test.py | H A D | 25-Apr-2025 | 798 | 27 | 8 | |
mac_test.sh | H A D | 25-Apr-2025 | 3.8 KiB | 133 | 61 | |
mac_test_keyset.json | H A D | 25-Apr-2025 | 387 | 14 | 13 |
README.md
1# Python MAC example 2 3This example shows how to check the integrity of data using Message 4Authentication Code (MAC). 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: 10 11```shell 12$ tinkey create-keyset --key-template HMAC_SHA256_256BITTAG --out-format JSON \ 13 --out mac_test_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 28Compute a MAC: 29 30```shell 31$ echo "some data" > data.txt 32$ touch mac_file.txt 33$ ./bazel-bin/mac/mac --mode compute \ 34 --keyset_path ./mac/mac_test_keyset.json \ 35 --data_path data.txt --mac_path mac_file.txt 36``` 37 38Verify a MAC: 39 40```shell 41$ ./bazel-bin/mac/mac --mode verify \ 42 --keyset_path ./mac/mac_test_keyset.json \ 43 --data_path data.txt --mac_path mac_file.txt 44``` 45