hmacsha256 c语言源码,纯C语言实现hmac sha256,可在单片机中使用_沃航科技

这是小沃最近遇到的一个项目,由于百度云的所有接口都需要通过hmac sha256计算,所以小沃在网上找到了相关代码可以在单片机中实现,现在就分享给大家。

SHA256.h#ifndef SHA256_H

#define SHA256_H

#include 

typedef struct {

uint8_t        hash[32];

uint32_t    buffer[16];

uint32_t    state[8];

uint8_t        length[8];

} sha256;

extern void sha256_get(uint8_t hash[32],

const uint8_t *message,

int length);

extern void hmac_sha256_get(uint8_t digest[32],

uint8_t *message, int message_length,

uint8_t *key, int key_length);

#endif

SHA256.c/*

* Copyright 2006 Apple Computer, Inc.  All rights reserved.

*

* iTunes U Sample Code License

* IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc. ("Apple")

* in consideration of your agreement to the following terms, and your use,

* installation, modification or distribution of this Apple software constitutes

* acceptance of these terms.  If you do not agree with these terms, please do not use,

* install, modify or distribute this Apple software.

*

* In consideration of your agreement to abide by the following terms and subject to

* these terms, Apple grants you a personal, non-exclusive, non-transferable license,

* under Apple's copyrights in this original Apple software (the "Apple Software"):

*

* (a) to internally use, reproduce, modify and internally distribute the Apple

* Software, with or without modifications, in source and binary forms, within your

* educational organization or internal campus network for the sole purpose of

* integrating Apple's iTunes U software with your internal campus network systems; and

*

* (b) to redistribute the Apple Software to other universities or educational

* organizations, with or without modifications, in source and binary forms, for the

* sole purpose of integrating Apple's iTunes U software with their internal campus

* network systems; provided that the following conditions are met:

*

*     -  If you redistribute the Apple Software in its entirety and without

*     modifications, you must retain the above copyright notice, this entire license

*     and the disclaimer provisions in all such redistributions of the Apple Software.

*     -  If you modify and redistribute the Apple Software, you must indicate that you

*     have made changes to the Apple Software, and you must retain the above

*     copyright notice, this entire license and the disclaimer provisions in all

*     such redistributions of the Apple Software and/or derivatives thereof created

*     by you.

*     -  Neither the name, trademarks, service marks or logos of Apple may be used to

*     endorse or promote products derived from the Apple Software without specific

*     prior written permission from Apple.

*

* Except as expressly stated above, no other rights or licenses, express or implied,

* ar

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值