Skip to content

maplefan/HMAC-SHA1-Base64

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HMAC-SHA1-Base64

HMAC-SHA1&Base64加密过程的Python实现以及使用C++实现。

How to use

// HMAC-SHA1 Base64 test program
#include<iostream>
#include"hmac.h"
#include"sha1.h"
#include"base64.h"

using namespace std;

int main(int argc, _TCHAR* argv[])
{
	std::string msg = "hello?world\n";
	cout<<msg.length()<<endl;;
    std::string key = "hahaha";
    std::string sha1hmac = hmac< SHA1 >(msg, key);
	cout<<"sha1hmac:"<<sha1hmac<<endl;
	string binDight , base64Str;
	string resNum = sha1hmac;
	HexToBin(resNum , binDight);//转化为原始二进制
	cout<<binDight<<endl;
	BinToBase64(binDight , base64Str);//原始二进制转化为Base64
	cout<<"结果为:"<<base64Str<<endl;
}
// HMAC-SHA1 Base64 test program
def hash_hmac(code, key):
  """sha1加密签名算法"""
  hmac_code = hmac.new(key.encode(), code.encode(), sha1).digest()
  return base64.b64encode(hmac_code).decode()

About

HMAC-SHA1&Base64加密过程的Python实现以及使用C++实现。

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages