Skip to main content
100%

Gist 22c21fedfe1389197d55288d2e2be93d

✓ Published0🌍 Public
CCarlos-Augusto
Last edited Feb 17, 2021
Created on Feb 17, 2021

This example demonstrates a Scala implementation of HMAC-SHA256 message authentication, showing how to generate a signed hash of the string "Hello World" using a hardcoded Base64-encoded secret key. It relies on the BouncyCastle cryptographic provider, added via `Security.addProvider`, and uses the Java Cryptography Architecture's `Mac` and `SecretKeySpec` classes to initialize the HMAC with the decoded key and the "HmacSHA256" algorithm. The code processes the input bytes through `mac.update` and finally outputs the resulting MAC as a Base64-encoded string, producing a specific authentication tag.

AI-generated description

Similar vizzes