Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | - | - | ||||
BUILD.bazel | H A D | 25-Apr-2025 | 1,000 | 34 | 29 | |
MacExample.java | H A D | 25-Apr-2025 | 2.8 KiB | 81 | 40 | |
README.md | H A D | 25-Apr-2025 | 781 | 34 | 23 | |
mac_example_test.sh | H A D | 25-Apr-2025 | 3.6 KiB | 126 | 55 | |
mac_test_keyset.json | H A D | 25-Apr-2025 | 387 | 14 | 13 |
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