BREW 普通MD5字符串编码实现,使用BREW的IHASH API.
输入要编码的字符串,可在输出窗口看到编码后的32位字符串。
void verify_md5(byte *input){ IHash* po = NULL; byte pResult[16]; int i = 0, ret = 0; int len = 16; char tmpstr[33], *p = tmpstr;
if (AEE_SUCCESS == ISHELL_CreateInstance(APP_SHELL, AEECLSID_MD5, (void**)&po)){ DBGPRINTF("---------md5 hase create instance OK-------------"); IHASH_Update(po, (byte*)input, STRLEN(input)); ret = IHASH_GetResult(po, pResult, &len); if(SUCCESS == ret){ for(i=0; i<16; i++){ p+= sprintf(p, "%02x", pResult[i]); } tmpstr[32] = '/0'; DBGPRINTF("before md5 str is: %s", (char *)input); DBGPRINTF("md5 str: %s", (char *)tmpstr); }else if(AEE_HASH_MORE_DATA == ret){ DBGPRINTF("---------Buffer not large enough to hold hashed result. -------------"); } else{ DBGPRINTF("---------get result error-------------"); } IHASH_Release(po);
}else{ DBGPRINTF("---------md5 hase create instance error-------------"); } }