`

SHA1摘要算法

阅读更多
#include <boost/uuid/sha1.hpp>
#include <iostream>
#include <string.h>
using namespace std;
using namespace boost::uuids::detail;

int main(){
    sha1 sha;
    char *szMsg = "a short message";
    sha.process_byte(0x10);//处理一个字节
    sha.process_bytes(szMsg,strlen(szMsg));//处理多个字节
    sha.process_block(szMsg,szMsg+strlen(szMsg));

    unsigned int digest[5];
    sha.get_digest(digest);
    for(int i=0;i<5;++i){
        cout << hex << digest[i];//16进制输出,oct八进制
    }
}

ae0871e0a767f827dbb07d259bf9b19b9933ce38
分享到:
评论
2 楼 zjx20 2012-05-14  
zjx20 写道
digest[]的字节序貌似是反的,直接输出会有问题

http://pastebin.com/8n1HqADw


是我错了
1 楼 zjx20 2012-05-14  
digest[]的字节序貌似是反的,直接输出会有问题

http://pastebin.com/8n1HqADw

相关推荐

Global site tag (gtag.js) - Google Analytics