Package com.itextpdf.text.pdf.security
Class DigestAlgorithms
- java.lang.Object
-
- com.itextpdf.text.pdf.security.DigestAlgorithms
-
public class DigestAlgorithms extends Object
Class that contains a map with the different message digest algorithms.
-
-
Field Summary
Fields Modifier and Type Field Description static StringRIPEMD160Algorithm available for signatures since PDF 1.7static StringSHA1Algorithm available for signatures since PDF 1.3static StringSHA256Algorithm available for signatures since PDF 1.6static StringSHA384Algorithm available for signatures since PDF 1.7static StringSHA512Algorithm available for signatures since PDF 1.7
-
Constructor Summary
Constructors Constructor Description DigestAlgorithms()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]digest(InputStream data, String hashAlgorithm, String provider)Creates a hash using a specific digest algorithm and a provider.static byte[]digest(InputStream data, MessageDigest messageDigest)static StringgetAllowedDigests(String name)Returns the id of a digest algorithms that is allowed in PDF, or null if it isn't allowed.static StringgetDigest(String oid)Gets the digest name for a certain idstatic MessageDigestgetMessageDigest(String hashAlgorithm, String provider)Creates a MessageDigest object that can be used to create a hash.static MessageDigestgetMessageDigestFromOid(String digestOid, String provider)static StringnormalizeDigestName(String algo)
-
-
-
Field Detail
-
SHA1
public static final String SHA1
Algorithm available for signatures since PDF 1.3- See Also:
- Constant Field Values
-
SHA256
public static final String SHA256
Algorithm available for signatures since PDF 1.6- See Also:
- Constant Field Values
-
SHA384
public static final String SHA384
Algorithm available for signatures since PDF 1.7- See Also:
- Constant Field Values
-
SHA512
public static final String SHA512
Algorithm available for signatures since PDF 1.7- See Also:
- Constant Field Values
-
RIPEMD160
public static final String RIPEMD160
Algorithm available for signatures since PDF 1.7- See Also:
- Constant Field Values
-
-
Method Detail
-
getMessageDigestFromOid
public static MessageDigest getMessageDigestFromOid(String digestOid, String provider) throws NoSuchAlgorithmException, NoSuchProviderException
-
getMessageDigest
public static MessageDigest getMessageDigest(String hashAlgorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException
Creates a MessageDigest object that can be used to create a hash.- Parameters:
hashAlgorithm- the algorithm you want to use to create a hashprovider- the provider you want to use to create the hash- Returns:
- a MessageDigest object
- Throws:
NoSuchAlgorithmExceptionNoSuchProviderExceptionGeneralSecurityException
-
digest
public static byte[] digest(InputStream data, String hashAlgorithm, String provider) throws GeneralSecurityException, IOException
Creates a hash using a specific digest algorithm and a provider.- Parameters:
data- the message of which you want to create a hashhashAlgorithm- the algorithm used to create the hashprovider- the provider used to create the hash- Returns:
- the hash
- Throws:
GeneralSecurityExceptionIOException
-
digest
public static byte[] digest(InputStream data, MessageDigest messageDigest) throws GeneralSecurityException, IOException
- Throws:
GeneralSecurityExceptionIOException
-
getDigest
public static String getDigest(String oid)
Gets the digest name for a certain id- Parameters:
oid- an id (for instance "1.2.840.113549.2.5")- Returns:
- a digest name (for instance "MD5")
-
-