使用的是OPENSSL中的EVP标准接口,现要要想对一字符串进行信息摘要,结果成功了,使用的是MD5算法,可有一点不会,就是如果要获取定长的MD5值如何实现,比如定长为8、12……20。千万不是对MD5值截取指定长度,而是设置一个什么参数。
还有,有朋友不推荐用MD5算法,我想采用SH1算法,如果SH1不支持定长,可以对SH1结果再进行MD5。熟悉这方面编程的朋友请帮帮忙,谢谢了。

解决方案 »

  1.   

    不可能,在OPENSSL的中文介绍中的《信息摘要算法概述》一节中讲得有,但没示例。
      

  2.   

    1. Executive Summary   This document describes the MD5 message-digest algorithm. The
       algorithm takes as input a message of arbitrary length and produces
       as output a 128-bit "fingerprint" or "message digest" of the input.
       It is conjectured that it is computationally infeasible to produce
       two messages having the same message digest, or to produce any
       message having a given prespecified target message digest. The MD5
       algorithm is intended for digital signature applications, where a
       large file must be "compressed" in a secure manner before being
       encrypted with a private (secret) key under a public-key cryptosystem
       such as RSA.   The MD5 algorithm is designed to be quite fast on 32-bit machines. In
       addition, the MD5 algorithm does not require any large substitution
       tables; the algorithm can be coded quite compactly.rfc中指出md5的结果是128bit,不符合rfc的就不叫md5。
      

  3.   

    哦,谢谢,那么OPENSSL的中文介绍中的《信息摘要算法概述》一节中讲的运用信息摘要算法实现获取定长摘要信息如何实现呢,是不是有其它办法,但应该不是对摘要信息按需截取的方法。