Name Date Size #Lines LOC

..--

BUILD.bazelH A D25-Apr-20251,000 3429

MacExample.javaH A D25-Apr-20252.8 KiB8140

README.mdH A D25-Apr-2025781 3423

mac_example_test.shH A D25-Apr-20253.6 KiB12655

mac_test_keyset.jsonH A D25-Apr-2025387 1413

README.md

1# Java MAC example
2
3This example shows how to check the integrity of data with Tink 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
12tinkey 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
20```shell
21git clone https://github.com/google/tink
22cd tink/examples/java_src
23bazel build ...
24
25echo "some data" > data.txt
26touch mac_file.txt
27
28./bazel-bin/mac/mac_example compute \
29    ./mac/mac_test_keyset.json data.txt mac_file.txt
30
31./bazel-bin/mac/mac_example verify \
32    ./mac/mac_test_keyset.json data.txt mac_file.txt
33```
34