3

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

Andrea Castro
  • 31
  • 1
  • 2
  • 1
    You can ! However, you have to create an algorithm first. MD5, SHA1, SHA256? What you wish to implement? Did you Google with the words `VBA SHA1 algorithm`there are several hits available – PaulFrancis Feb 11 '15 at 11:47
  • HAve you tried make it work? i tried for few days without success changing the vba amd so on...did you make it? – Andrea Castro Feb 12 '15 at 22:56
  • FWIW I posted an Excel no-vba version of SHA256 to answer this question: https://stackoverflow.com/questions/46509572/excel-formula-based-function-for-sha256-sha512-hashing-without-vba-or-macros/56767828#56767828 – pgSystemTester Jun 27 '19 at 17:42

1 Answers1

3

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.

i_saw_drones
  • 3,486
  • 1
  • 31
  • 50
  • HAve you tried make it work? i tried for few days without success changing the vba amd so on...did you make it? – Andrea Castro Feb 12 '15 at 22:57
  • Sorry, which part do you mean - the VB6, or the .NET solution? In either case, please update your question with details of the issues you are experiencing including sample code so that we can help you... – i_saw_drones Feb 13 '15 at 10:26