Class CryptMD5


  • public class CryptMD5
    extends Object
    The MD5 algorithm (Message Digest 5).

    It is a one-way hashing function that compute a 128-bit digest of a message (generally a file). It is not for encrypting password but for generating a digest of a content in order to sign it and to ensure its integrity.

    A first flaw (possibility to create collisions at the demand) was discovered in 1996. In 2004, a chinese team broke it by discovering full collisions. Since, it was replaced first by the SHA-1 algorithm and now the SHA-2 algorithms are used (SHA-256, SHA-512).

    • Method Detail

      • encrypt

        public static String encrypt​(String original)
                              throws org.silverpeas.kernel.SilverpeasRuntimeException
        Encrypts the specified text in MD5.
        Parameters:
        original - the text to encrypt
        Returns:
        the digest of the text in a 32-bits hexadecimal.
        Throws:
        org.silverpeas.kernel.SilverpeasRuntimeException - if an error occurs.
      • encrypt

        public static String encrypt​(File file)
                              throws org.silverpeas.kernel.SilverpeasRuntimeException
        Computes the MD5 hash of a file.
        Parameters:
        file - the file to be MD5 hashed.
        Returns:
        the MD5 hash as a String.
        Throws:
        org.silverpeas.kernel.SilverpeasRuntimeException - if an error occurs.