利用TomLibCrypt库实现hash算法
利用LibTomCrypt密码算法库中提供的哈希算法相关函数对一个文件进行处理,计算该文件的SHA-1值、SHA-256值和SHA-512值,提交程序代码和运算结果;
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1866 2013-11-29 11:20 hashhashhash.cpp
文件 5403 2013-11-28 10:24 hashhashhash.vcxproj
文件 2646 2013-11-28 10:24 hashhashhash.vcxproj.filters
文件 143 2013-11-28 10:24 hashhashhash.vcxproj.user
文件 2543 2007-05-12 22:46 hashhashheaders omcrypt.h
文件 977 2007-05-12 22:46 hashhashheaders omcrypt_argchk.h
文件 3869 2007-05-12 22:46 hashhashheaders omcrypt_cfg.h
文件 31702 2007-05-12 22:46 hashhashheaders omcrypt_cipher.h
文件 8392 2007-05-12 22:46 hashhashheaders omcrypt_custom.h
文件 12457 2007-05-12 22:46 hashhashheaders omcrypt_hash.h
文件 14482 2007-05-12 22:46 hashhashheaders omcrypt_mac.h
文件 14365 2007-05-12 22:46 hashhashheaders omcrypt_macros.h
文件 17093 2007-05-12 22:46 hashhashheaders omcrypt_math.h
文件 691 2007-05-12 22:46 hashhashheaders omcrypt_misc.h
文件 21016 2007-05-12 22:46 hashhashheaders omcrypt_pk.h
文件 3989 2007-05-12 22:46 hashhashheaders omcrypt_pkcs.h
文件 7224 2007-05-12 22:46 hashhashheaders omcrypt_prng.h
文件 1132226 2011-11-08 10:27 hashhashlib_release omcrypt.lib
文件 141570 2011-11-08 11:27 hashhashlib_release ommath.lib
文件 1532 2013-11-28 10:24 hashhashReadMe.txt
文件 209 2013-11-28 10:24 hashhashstdafx.cpp
文件 233 2013-11-28 10:24 hashhashstdafx.h
文件 236 2013-11-28 10:24 hashhash argetver.h
文件 3493888 2013-12-09 11:13 hashhash.sdf
文件 884 2013-11-28 13:08 hashhash.sln
..A..H. 14848 2013-12-09 11:13 hashhash.suo
文件 2359296 2013-12-09 11:13 hashipchhash-925a3ccahash-dc5cb190.ipch
目录 0 2013-12-09 11:12 hashhashDebug
..AD... 0 2013-12-09 11:11 hashhashheaders
..AD... 0 2013-12-09 11:11 hashhashlib_release
............此处省略8个文件信息
// hash.cpp : 定义控制台应用程序的入口点。
//
#include “stdafx.h“
#include “stdlib.h“
#include
int main(int argc _TCHAR* argv[])
{
int idx err;
unsigned long len;
unsigned char out[MAXBLOCKSIZE];
/* register the hash */
if (register_hash(&sha1_desc) == -1) {
system(“pause“);
printf(“Error registering sha1.
“);
return -1;
}
/* get the index of the hash */
idx = find_hash(“sha1“);
/* call the hash */
len = sizeof(out);
const unsigned char p[9] = {“11285024“};
if ((err =hash_memory( idxp8out&len)) != CRYPT_OK) {
printf(“Error hashing data: %s
“ error_to_string(err));
system(“pause“);
return -1;
}
printf(“The sha1 value is:“);
for(int i=0;i {
printf(“%x“out[i]);
}
printf(“
“);
/* register the hash */
if (register_hash(&sha256_desc) == -1) {
system(“pause“);
printf(“Error registering sha1.
“);
return -1;
}
/* get the index of the hash */
idx = find_hash(“sha256“);
/* call the hash */
len = sizeof(out);
if ((err =hash_memory( idxp8out&len)) != CRYPT_OK) {
printf(“Error hashing data: %s
“ error_to_string(err));
system(“pause“);
return -1;
}
printf(“The sha256 value is:“);
for(int i=0;i {
printf(“%x“out[i]);
}
printf(“
“);
/* register the hash */
if (register_hash(&sha512_desc) == -1) {
system(“pause“);
printf(“Error registering sha1.
“);
return -1;
}
/* get the index of the hash */
idx = find_hash(“sha512“);
/* call the hash */
len = sizeof(out);
if ((err =hash_memory( idxp8out&len)) != CRYPT_OK) {
printf(“Error hashing data: %s
“ error_to_string(err));
system(“pause“);
return -1;
}
printf(“The sha512 value is:“);
for(int i=0;i {
printf(“%x“out[i]);
}
printf(“
“);
system(“pause“);
return 0;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1866 2013-11-29 11:20 hashhashhash.cpp
文件 5403 2013-11-28 10:24 hashhashhash.vcxproj
文件 2646 2013-11-28 10:24 hashhashhash.vcxproj.filters
文件 143 2013-11-28 10:24 hashhashhash.vcxproj.user
文件 2543 2007-05-12 22:46 hashhashheaders omcrypt.h
文件 977 2007-05-12 22:46 hashhashheaders omcrypt_argchk.h
文件 3869 2007-05-12 22:46 hashhashheaders omcrypt_cfg.h
文件 31702 2007-05-12 22:46 hashhashheaders omcrypt_cipher.h
文件 8392 2007-05-12 22:46 hashhashheaders omcrypt_custom.h
文件 12457 2007-05-12 22:46 hashhashheaders omcrypt_hash.h
文件 14482 2007-05-12 22:46 hashhashheaders omcrypt_mac.h
文件 14365 2007-05-12 22:46 hashhashheaders omcrypt_macros.h
文件 17093 2007-05-12 22:46 hashhashheaders omcrypt_math.h
文件 691 2007-05-12 22:46 hashhashheaders omcrypt_misc.h
文件 21016 2007-05-12 22:46 hashhashheaders omcrypt_pk.h
文件 3989 2007-05-12 22:46 hashhashheaders omcrypt_pkcs.h
文件 7224 2007-05-12 22:46 hashhashheaders omcrypt_prng.h
文件 1132226 2011-11-08 10:27 hashhashlib_release omcrypt.lib
文件 141570 2011-11-08 11:27 hashhashlib_release ommath.lib
文件 1532 2013-11-28 10:24 hashhashReadMe.txt
文件 209 2013-11-28 10:24 hashhashstdafx.cpp
文件 233 2013-11-28 10:24 hashhashstdafx.h
文件 236 2013-11-28 10:24 hashhash argetver.h
文件 3493888 2013-12-09 11:13 hashhash.sdf
文件 884 2013-11-28 13:08 hashhash.sln
..A..H. 14848 2013-12-09 11:13 hashhash.suo
文件 2359296 2013-12-09 11:13 hashipchhash-925a3ccahash-dc5cb190.ipch
目录 0 2013-12-09 11:12 hashhashDebug
..AD... 0 2013-12-09 11:11 hashhashheaders
..AD... 0 2013-12-09 11:11 hashhashlib_release
............此处省略8个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)