打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Arduino 的MD5库 | www.lab

这是来自 http://playground.arduino.cc/Main/LibraryList 的Arduino MD5库【参考1】。我实验了一下挺好用的。

01#include "MD5.h"
02/*
03This is en example of how to use my MD5 library. It provides two
04easy-to-use methods, one for generating the MD5 hash, and the second
05one to generate the hex encoding of the hash, which is frequently used.
06*/
07void setup()
08{
09  //initialize serial
10  Serial.begin(9600);
11  //give it a second
12  delay(1000);
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);
19 
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);  
24 
25}
26 
27void loop()
28{
29}

 

运行结果

这个结果和我在一个在线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在线计算网站

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Arduino和非Arduino板串口通信教程
Arduino 中断测试 ? 踢踢蚂蚁
ARDUINO MEGA2560 经过ESP8266 WIFI模块上传温湿度数据到 OneNet 服务器
用Arduino和DS1302时钟模块做个简易电子钟
arduino+w5100获取网络时间采用12864液晶显示
Arduino教程学习A17
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服