std::string Md5 (const void* str, size_t length, size_t block_length){ MD5_CTX md5_ctx = { 0 }; unsigned char sign[16] = { 0 }; if (length){ MD5_Init (&md5_ctx); MD5_Update (&md5_ctx, str, length); MD5_Final (sign, &md5_ctx); } if (block_length){ return std::string (HexStrFormByteArray (sign, 16), 0, block_length); } else{ return std::string (HexStrFormByteArray (sign, 16), 0); } } std::string HexStrFormByteArray (unsigned char *data, int len){ std::stringstream ss; ss << std::hex << std::setw (2) << std::setfill ( for (int i (0); i < len; ++i){ ss << (int)data[i] << std::setw (2) << std::setfill ( } return std::string (ss.str ()); }
这个断是c语言的加密,主要是HexStrFormByteArray这个最终结果导致和易的md5加密结果不一样,请问能帮忙翻一下吗谢谢
|