tree: 013e75739419fdbe3cc5f6ba85edaf8be1667739 [path history] [tgz]
  1. file_mac_cleartext.py
  2. file_mac_test.sh
  3. hmac_sha256_256bittag_test_keyset.json
  4. README.md
examples/file_mac/python/README.md

Python File MAC

This is a command-line tool that can check the integrity of a file using MAC (Message Authentication Code).

It demonstrates the basic steps of using Tink, namely loading key material, obtaining a primitive, and using the primitive to do crypto.

Moreover, since this app shares the same Bazel WORKSPACE with Tink, its BUILD file can directly depend on Tink.

The key material was generated with:

tinkey create-keyset --key-template HMAC_SHA256_256BITTAG --out-format JSON \
--out tmp/hmac_sha256_256bittag_test_keyset.json

Build and Run

Bazel

git clone https://github.com/google/tink
cd tink
bazel build ...
echo "some data" > data.txt
echo "01293ce6590fb883aa111a53e56d537dea5641b664901e35ce10e0c31df8398218fa9b030d" > expected.txt

./bazel-bin/examples/file_mac/python/file_mac ./examples/file_mac/python/hmac_sha256_256bittag_test_keyset.json \
    data.txt
./bazel-bin/examples/file_mac/python/file_mac ./examples/file_mac/python/hmac_sha256_256bittag_test_keyset.json \
    data.txt expected.txt