資源簡介
STM32F407+ESP8266連接阿里云實現Iot,協議MQTT, ESP8266用的是AT指令。
代碼片段和文件信息
/*-------------------------------------------------*/
/*???????????????超緯電子開發板????????????????????*/
/*????淘寶地址:?http://chaoweidianzi.taobao.com???*/
/*-------------------------------------------------*/
/*?????????????????????????????????????????????????*/
/*??????????????網上尋找的開源程序?????????????????*/
/*?????????????????????????????????????????????????*/
/*-------------------------------------------------*/
#include?“utils_hmac.h“
#include?“utils_md5.h“
#include?“utils_sha1.h“
#define?KEY_IOPAD_SIZE?64
#define?MD5_DIGEST_SIZE?16
#define?SHA1_DIGEST_SIZE?20
const?char?*?base64char?=?“ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/“;
/*-------------------------------------------------*/
/*函數名:hmacmd5編碼??????????????????????????????*/
/*網上尋找的開源程序???????????????????????????????*/
/*-------------------------------------------------*/
void?utils_hmac_md5(const?char?*msg?int?msg_len?char?*digest?const?char?*key?int?key_len)
{
unsigned?char?k_ipad[KEY_IOPAD_SIZE];????/*?inner?padding?-?key?XORd?with?ipad??*/
????unsigned?char?k_opad[KEY_IOPAD_SIZE];????/*?outer?padding?-?key?XORd?with?opad?*/
????unsigned?char?out[MD5_DIGEST_SIZE];
????int?i;
iot_md5_context?context;
if((NULL?==?msg)?||?(NULL?==?digest)?||?(NULL?==?key))?{
????????return;
????}
????if(key_len?>?KEY_IOPAD_SIZE)?{
????????return;
????}
????/*?start?out?by?storing?key?in?pads?*/
????memset(k_ipad?0?sizeof(k_ipad));
????memset(k_opad?0?sizeof(k_opad));
????memcpy(k_ipad?key?key_len);
????memcpy(k_opad?key?key_len);
????/*?XOR?key?with?ipad?and?opad?values?*/
????for?(i?=?0;?i?????????k_ipad[i]?^=?0x36;
????????k_opad[i]?^=?0x5c;
????}
????/*?perform?inner?MD5?*/
????utils_md5_init(&context);??????????????????????????????????????/*?init?context?for?1st?pass?*/
????utils_md5_starts(&context);????????????????????????????????????/*?setup?context?for?1st?pass?*/
????utils_md5_update(&context?k_ipad?KEY_IOPAD_SIZE);????????????/*?start?with?inner?pad?*/
????utils_md5_update(&context?(unsigned?char?*)?msg?msg_len);????/*?then?text?of?datagram?*/
????utils_md5_finish(&context?out);???????????????????????????????/*?finish?up?1st?pass?*/
????/*?perform?outer?MD5?*/
????utils_md5_init(&context);??????????????????????????????/*?init?context?for?2nd?pass?*/
????utils_md5_starts(&context);????????????????????????????/*?setup?context?for?2nd?pass?*/
????utils_md5_update(&context?k_opad?KEY_IOPAD_SIZE);????/*?start?with?outer?pad?*/
????utils_md5_update(&context?out?MD5_DIGEST_SIZE);??????/*?then?results?of?1st?hash?*/
????utils_md5_finish(&context?out);???????????????????????/*?finish?up?2nd?pass?*/
????for?(i?=?0;?i?????????digest[i?*?2]?=?utils_hb2hex(out[i]?>>?4);
????????digest[i?*?2?+?1]?=?utils_hb2hex(out[i]);
????}
}
/*-------------------------------------------------*/
/*函數名:hmacsha1編碼?????????????????????????????*/
/*網上尋找
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????1048576??2017-11-30?17:13??Ai-Thinker_ESP8266_DOUT_8Mbit_v1.5.4.1-a_20171130.bin
?????目錄???????????0??2019-07-01?10:34??STM32F407+ESP8266?阿里云Iot\
?????目錄???????????0??2019-07-01?10:34??STM32F407+ESP8266?阿里云Iot\Software\
?????目錄???????????0??2019-06-28?15:16??STM32F407+ESP8266?阿里云Iot\Software\HMAC\
?????目錄???????????0??2019-06-28?15:16??STM32F407+ESP8266?阿里云Iot\Software\HMAC\inc\
?????文件?????????628??2018-09-30?14:13??STM32F407+ESP8266?阿里云Iot\Software\HMAC\inc\utils_hmac.h
?????文件????????2281??2018-09-09?15:52??STM32F407+ESP8266?阿里云Iot\Software\HMAC\inc\utils_md5.h
?????文件????????2462??2018-09-09?15:52??STM32F407+ESP8266?阿里云Iot\Software\HMAC\inc\utils_sha1.h
?????目錄???????????0??2019-06-28?15:16??STM32F407+ESP8266?阿里云Iot\Software\HMAC\scr\
?????文件????????6764??2018-09-30?14:13??STM32F407+ESP8266?阿里云Iot\Software\HMAC\scr\utils_hmac.c
?????文件????????8758??2018-09-09?15:52??STM32F407+ESP8266?阿里云Iot\Software\HMAC\scr\utils_md5.c
?????文件????????9051??2018-09-09?15:52??STM32F407+ESP8266?阿里云Iot\Software\HMAC\scr\utils_sha1.c
?????目錄???????????0??2019-06-28?08:49??STM32F407+ESP8266?阿里云Iot\Software\Libraries\
?????目錄???????????0??2019-06-28?08:49??STM32F407+ESP8266?阿里云Iot\Software\Libraries\CMSIS\
?????文件??????109142??2014-07-17?21:52??STM32F407+ESP8266?阿里云Iot\Software\Libraries\CMSIS\core_cm4.h
?????文件???????22735??2014-07-17?21:52??STM32F407+ESP8266?阿里云Iot\Software\Libraries\CMSIS\core_cm4_simd.h
?????文件???????17146??2014-07-17?21:52??STM32F407+ESP8266?阿里云Iot\Software\Libraries\CMSIS\core_cmFunc.h
?????文件???????20513??2014-07-17?21:52??STM32F407+ESP8266?阿里云Iot\Software\Libraries\CMSIS\core_cmInstr.h
?????文件???????29605??2014-08-02?00:12??STM32F407+ESP8266?阿里云Iot\Software\Libraries\CMSIS\startup_stm32f40_41xxx.s
?????目錄???????????0??2019-06-28?08:49??STM32F407+ESP8266?阿里云Iot\Software\Libraries\Stm32f40x_StdPeriph_Driver\
?????目錄???????????0??2019-06-28?08:49??STM32F407+ESP8266?阿里云Iot\Software\Libraries\Stm32f40x_StdPeriph_Driver\inc\
?????文件????????6924??2014-08-01?23:18??STM32F407+ESP8266?阿里云Iot\Software\Libraries\Stm32f40x_StdPeriph_Driver\inc\misc.h
?????文件???????32880??2014-08-01?23:18??STM32F407+ESP8266?阿里云Iot\Software\Libraries\Stm32f40x_StdPeriph_Driver\inc\stm32f4xx_adc.h
?????文件???????27318??2014-08-01?23:18??STM32F407+ESP8266?阿里云Iot\Software\Libraries\Stm32f40x_StdPeriph_Driver\inc\stm32f4xx_can.h
?????文件????????2416??2014-08-01?23:18??STM32F407+ESP8266?阿里云Iot\Software\Libraries\Stm32f40x_StdPeriph_Driver\inc\stm32f4xx_crc.h
?????文件???????14481??2014-08-01?23:18??STM32F407+ESP8266?阿里云Iot\Software\Libraries\Stm32f40x_StdPeriph_Driver\inc\stm32f4xx_cryp.h
?????文件???????14946??2014-08-01?23:18??STM32F407+ESP8266?阿里云Iot\Software\Libraries\Stm32f40x_StdPeriph_Driver\inc\stm32f4xx_dac.h
?????文件????????4296??2014-08-01?23:18??STM32F407+ESP8266?阿里云Iot\Software\Libraries\Stm32f40x_StdPeriph_Driver\inc\stm32f4xx_dbgmcu.h
?????文件???????12977??2014-08-01?23:18??STM32F407+ESP8266?阿里云Iot\Software\Libraries\Stm32f40x_StdPeriph_Driver\inc\stm32f4xx_dcmi.h
?????文件???????28882??2014-08-01?23:18??STM32F407+ESP8266?阿里云Iot\Software\Libraries\Stm32f40x_StdPeriph_Driver\inc\stm32f4xx_dma.h
?????文件???????19692??2014-08-01?23:18??STM32F407+ESP8266?阿里云Iot\Software\Libraries\Stm32f40x_StdPeriph_Driver\inc\stm32f4xx_dma2d.h
............此處省略303個文件信息
評論
共有 條評論