Andrea Castro
Andrea Castro

Reputation: 31

HMAC SHA256 macro in Excel

I search ed through google, tech forums, etc.... but I couldn't find a good tutorial/guide that answer my question:

I have a Cell in Excel with Text, and a Cell with a Key(both text), is there a way to have an HMAC for EXCEL function that get both cell as input and return the hmac text ?

thanks in advance

Upvotes: 3

Views: 7823

Answers (1)

i_saw_drones
i_saw_drones

Reputation: 3506

A quick search on Google revealed a HMAC-SHA256 class written in VB6, located here: http://www.vbforums.com/showthread.php?635398-VB6-HMAC-SHA-256-HMAC-SHA-1-Using-Crypto-API

Whilst this is for VB6 (and is native code), it should be straightforward to adapt for use with VBA. As it sounds that you need a worksheet function (i.e. UDF) then you will also need to write this, using the above class.

If you're happy to call .NET assemblies from VBA, then you can simplify your code as most of the calculation work is already done for you (see System.Security.Cryptography, more specifically HMACSHA256). An example (for HMACSHA1, but the principle is the same) is given here: Does VBA have a Hash_HMAC.

Upvotes: 3

Related Questions