基本信息
源码名称:hmac_sha1(c++示例)
源码大小:0.25M
文件格式:.rar
开发语言:C/C++
更新时间:2021-03-30
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
#include <cryptlite/base64.h>
#include <cryptlite/sha1.h>
#include <cryptlite/sha256.h>
#include <cryptlite/hmac.h>
#include <boost/cstdint.hpp>
using namespace cryptlite;
// base64 encoding
std::string b64 = base64::encode_from_string("foobarbuz");
std::vector<boost::uint8_t> decoded_v;
base64::decode(b64, decoded_v);
std::string decoded_str;
base64::decode(b64, decoded_str);
boost::shared_array<boost::uint8_t> arr;
std::size_t len;
boost::tie(arr, len) = base64::decode_to_array(b64);
// sha1 hash
boost::uint8_t sha1digest[sha1::HASH_SIZE];
sha1::hash("foobar", sha1digest);
// hex-formatted sha1 hash
std::string sha1hex = sha1::hash_hex("foobar");
// base64-formatted sha1 hash
std::string sha1base64 = sha1::hash_base64("foobar");
// sha256 hash
boost::uint8_t sha256digest[sha256::HASH_SIZE];
sha256::hash("foobar", sha256digest);
// hex-formatted sha256 hash
std::string sha256hex = sha256::hash_hex("foobar");
// base64-formatted sha256 hash
std::string sha256base64 = sha256::hash_base64("foobar");
// calculate hmac-sha1
boost::uint8_t hmacsha1digest[sha1::HASH_SIZE];
hmac<sha1>::calc("basestring", "key", hmacsha1digest);
// calculate hex-formatted hmac-sha1
std::string hmacsha1hex = hmac<sha1>::calc_hex("basestring", "key");
// calculate hmac-sha256
boost::uint8_t hmacsha256digest[sha256::HASH_SIZE];
hmac<sha256>::calc("basestring", "key", hmacsha256digest);
// calculate hex-formatted hmac-sha256
std::string hmacsha256hex = hmac<sha256>::calc_hex("basestring", "key");
#include <cryptlite/base64.h>
#include <cryptlite/sha1.h>
#include <cryptlite/sha256.h>
#include <cryptlite/hmac.h>
#include <boost/cstdint.hpp>
using namespace cryptlite;
// base64 encoding
std::string b64 = base64::encode_from_string("foobarbuz");
std::vector<boost::uint8_t> decoded_v;
base64::decode(b64, decoded_v);
std::string decoded_str;
base64::decode(b64, decoded_str);
boost::shared_array<boost::uint8_t> arr;
std::size_t len;
boost::tie(arr, len) = base64::decode_to_array(b64);
// sha1 hash
boost::uint8_t sha1digest[sha1::HASH_SIZE];
sha1::hash("foobar", sha1digest);
// hex-formatted sha1 hash
std::string sha1hex = sha1::hash_hex("foobar");
// base64-formatted sha1 hash
std::string sha1base64 = sha1::hash_base64("foobar");
// sha256 hash
boost::uint8_t sha256digest[sha256::HASH_SIZE];
sha256::hash("foobar", sha256digest);
// hex-formatted sha256 hash
std::string sha256hex = sha256::hash_hex("foobar");
// base64-formatted sha256 hash
std::string sha256base64 = sha256::hash_base64("foobar");
// calculate hmac-sha1
boost::uint8_t hmacsha1digest[sha1::HASH_SIZE];
hmac<sha1>::calc("basestring", "key", hmacsha1digest);
// calculate hex-formatted hmac-sha1
std::string hmacsha1hex = hmac<sha1>::calc_hex("basestring", "key");
// calculate hmac-sha256
boost::uint8_t hmacsha256digest[sha256::HASH_SIZE];
hmac<sha256>::calc("basestring", "key", hmacsha256digest);
// calculate hex-formatted hmac-sha256
std::string hmacsha256hex = hmac<sha256>::calc_hex("basestring", "key");