{ "cells": [ { "cell_type": "markdown", "id": "advised-checkout", "metadata": {}, "source": [ "## Hash-based Message Authentication Codes\n", "\n", "[https://en.wikipedia.org/wiki/HMAC]\n", "\n", "In cryptography, an HMAC (sometimes expanded as either keyed-hash\n", "message authentication code or hash-based message authentication code)\n", "is a specific type of message authentication code (MAC) involving a\n", "cryptographic hash function and a secret cryptographic key. As with\n", "any MAC, it may be used to simultaneously verify both the data\n", "integrity and authenticity of a message.\n", "\n", " select crypto_auth_hmacsha512_keygen() hmac512key \\gset\n", " select crypto_auth_hmacsha512('food', :'hmac512key') hmac512 \\gset\n", "\n", " select is(crypto_auth_hmacsha512_verify(:'hmac512', 'food', :'hmac512key'), true, 'hmac512 verified');\n", " select is(crypto_auth_hmacsha512_verify(:'hmac512', 'fo0d', :'hmac512key'), false, 'hmac512 not verified');\n", "\n", "[C API Documentation](https://doc.libsodium.org/advanced/hmac-sha2)\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.2" } }, "nbformat": 4, "nbformat_minor": 5 }