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