使用开源代码CSHA1 - A,计算文件和字符串SHA1
2015-10-15 10:57
363 查看
使用开源代码,计算文件和字符串SHA1
开源项目:
http://www.codeproject.com/Articles/2463/CSHA1-A-C-Class-Implementation-of-the-SHA-1-Hash-A
开源项目:
http://www.codeproject.com/Articles/2463/CSHA1-A-C-Class-Implementation-of-the-SHA-1-Hash-A
void GetSHA() { int iIndex = -1; CSHA1 sha1; do { printf("输入数字选择想校验SHA1的类型:\nFile is 1 \nString is 2 \nExit is 3 \r\n"); scanf("%d",&iIndex); if (iIndex == 1) { TCHAR str[] = {0}; printf("请输入文件名全路径或者直接拖到DOS窗口\n"); scanf("%s",str); sha1.HashFile(str); sha1.Final(); TCHAR tszReport[41]; sha1.ReportHash(tszReport, CSHA1::REPORT_HEX_SHORT); _tprintf(_T("\r\n File hashed to:\r\n ")); _tprintf(tszReport); _tprintf(_T("\n")); } if (iIndex == 2) { char chTemp[128] = {0}; printf("请输入字符串\r\n"); scanf("%s",chTemp); sha1.Update(reinterpret_cast<const unsigned char*>(chTemp), strlen(chTemp)); sha1.Final(); std::basic_string<TCHAR> strReport; sha1.ReportHashStl(strReport, CSHA1::REPORT_HEX_SHORT); _tprintf(_T("\r\n String hashed to:\r\n ")); _tprintf(strReport.c_str()); _tprintf(_T("\r\n")); // std::cout<<"Hash is :["<<hex<<strReport.c_str()<<"]"<<endl; } sha1.Reset(); } while (iIndex != 3); }
相关文章推荐
- Java开发中的23种设计模式详解
- Struts2中动态方法的调用
- c# 关于浅拷贝和深拷贝
- Eclipse导入外部项目问题总结1
- Java之静态内部类(static class)
- 大话西游之设计模式_起手篇
- 通过Spring工具类获取classpath下的文件资源--笔记
- windows service 2012:[7]搭建FTP服务器
- eclipse 使用
- windows service 2012:[7]搭建FTP服务器
- windows service 2012:[7]搭建FTP服务器
- 杨辉三角——C#语言
- C# Window编程随记——新建一个window项目
- 联系人的获取--ContentProvider
- Java EE7和Maven工程入门
- 测试开发Python培训:实现屌丝的图片收藏愿望(小插曲)
- JavaMockito的使用
- Struts2 中遇到的问题
- Matlab 字符串处理函数
- 在搭建好Android SDK的Eclipse中截取手机屏幕