重新组织编写Delphi的MD2、MD4、MD5类

     在Delphi中,由于Indy的TIdHashMessageDigest类有BUG(见我的《要谨慎使用Indy的TIdHashMessageDigest类》一文),只好重新借Indy代码重新组织改写了一下,经过简单测试正常,源码如下,如有错误请指正:

   

int main(int argc, char *argv[]) { int i = 0; bool bOnce = true; char szPath[RH_MAX_PATH]; char szAbsPath[RH_MAX_PATH]; char szOrgPath[RH_MAX_PATH]; char szTemp[RH_MAX_BUFFER]; int iErrorCode = 0; CHashManager hashmgr; getcwd(szOrgPath, RH_MAX_PATH); //No arguments? if(argc == 1) { printInfo(); return(RH_NO_ARGS); } memset(szPath, 0, RH_MAX_PATH); bOnce = true; hashmgr.SelectAllAlgorithms(true); for(i = 1; i = RH_MAX_BUFFER) continue; // Non-parsable option argument, ignore fmtArgument(argv[i], szTemp); // Format the argument, i.e. remove all special chars if(strcmp(szTemp, "help" ) == 0) printInfo(); if(strcmp(szTemp, "h" ) == 0) printInfo(); if(strcmp(szTemp, "?" ) == 0) printInfo(); if(strcmp(szTemp, "version" ) == 0) printInfo(); if(strcmp(szTemp, "v" ) == 0) printInfo(); if(strcmp(szTemp, "fullpath") == 0) hashmgr.SetOption(OPT_FULLPATH, true); if(strcmp(szTemp, "f" ) == 0) hashmgr.SetOption(OPT_FULLPATH, true); if(strcmp(szTemp, "nopath" ) == 0) hashmgr.SetOption(OPT_FULLPATH, false); if(strcmp(szTemp, "rcrsv" ) == 0) hashmgr.SetOption(OPT_RECURSIVE, true); if(strcmp(szTemp, "norcrsv" ) == 0) hashmgr.SetOption(OPT_RECURSIVE, false); if(strcmp(szTemp, "recur" ) == 0) hashmgr.SetOption(OPT_RECURSIVE, true); if(strcmp(szTemp, "norecur" ) == 0) hashmgr.SetOption(OPT_RECURSIVE, false); if(strcmp(szTemp, "r" ) == 0) hashmgr.SetOption(OPT_RECURSIVE, true); if(strcmp(szTemp, "all" ) == 0) hashmgr.SelectAllAlgorithms(true); if(strcmp(szTemp, "a" ) == 0) hashmgr.SelectAllAlgorithms(true); if(strcmp(szTemp, "none" ) == 0) hashmgr.SelectAllAlgorithms(false); if(strcmp(s
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值