这是来自 http://playground.arduino.cc/Main/LibraryList 的Arduino MD5库【参考1】。我实验了一下挺好用的。
03 | This is en example of how to use my MD5 library. It provides two |
04 | easy-to-use methods, one for generating the MD5 hash, and the second |
05 | one to generate the hex encoding of the hash, which is frequently used. |
13 | //generate the MD5 hash for our string |
14 | unsigned char * hash=MD5::make_hash( "hello world" ); |
15 | //generate the digest (hex encoding) of our hash |
16 | char *md5str = MD5::make_digest(hash, 16); |
17 | //print it on our serial monitor |
18 | Serial.println(md5str); |
20 | char * test= "hello world" ; |
21 | unsigned char * hash2=MD5::make_hash(test); |
22 | md5str=MD5::make_digest((unsigned char *)hash2, 16); |
23 | Serial.println(md5str); |
运行结果
这个结果和我在一个在线MD5的网站【参考2】计算结果是一致的
例子下载
MD5_Hash
我只是简单的测试了一下对Char做MD5,头文件中的另外几个函数的用法没搞清楚。从经验上来看,应该是能够不断累积计算一系列MD5值(比如说刚开始有个字符串”ABC”后来又来了一个字符串“DEF”可以继续加入计算中)。试验了一下没搞清楚。
static const void *body(void *ctxBuf, const void *data, size_t size);
static void MD5Init(void *ctxBuf);
static void MD5Final(unsigned char *result, void *ctxBuf);
static void MD5Update(void *ctxBuf, const void *data, size_t size);
参考:
1.https://github.com/tzikis/ArduinoMD5/ 完整代码下载 ArduinoMD5-master
2.http://md5calculator.chromefans.org/ 一个MD5在线计算网站
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。