HMAC SHA256宏在Excel中 [英] HMAC SHA256 macro in Excel

查看:405
本文介绍了HMAC SHA256宏在Excel中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过谷歌,技术论坛等搜索...但是我找不到一个很好的教程/指南来回答我的问题:



我有一个带有文本的Excel单元格和一个带有键的单元格(两个文本),是否有一种方法可以让一个HMAC的EXCEL函数将这两个单元格作为输入并返回hmac文本?



提前感谢

解决方案

Google快速搜索揭示了一个用VB6编写的HMAC-SHA256类,位于这里: http ://www.vbforums.com/showthread.php?635398-VB6-HMAC-SHA-256-HMAC-SHA-1-Use-Crypto-API



虽然这是针对VB6(和本机代码),但是应该直接适应VBA的使用。因为它听起来需要一个工作表函数(即UDF),那么你也需要使用上面的类写这个。



如果你很乐意打电话。 NET组件,那么您可以简化代码,因为大多数计算工作已经为您完成(请参阅System.Security.Cryptography,更具体地说HMACSHA256)。一个例子(对于HMACSHA1,但原理是一样的): VBA是否具有一个Hash_HMAC


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

解决方案

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.

这篇关于HMAC SHA256宏在Excel中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆