org.carlspring.commons.encryption.EncryptionAlgorithmsEnum Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-io Show documentation
Show all versions of commons-io Show documentation
A set of common IO classes
package org.carlspring.commons.encryption;
import java.io.IOException;
/**
* @author mtodorov
*/
public enum EncryptionAlgorithmsEnum
{
MD5("MD5", ".md5"),
SHA1("SHA-1", ".sha1");
private String extension;
private String algorithm;
EncryptionAlgorithmsEnum(String algorithm, String extension)
{
this.algorithm = algorithm;
this.extension = extension;
}
public String getExtension()
{
return extension;
}
public void setExtension(String extension)
{
this.extension = extension;
}
public String getAlgorithm()
{
return algorithm;
}
public void setAlgorithm(String algorithm)
{
this.algorithm = algorithm;
}
public static EncryptionAlgorithmsEnum fromAlgorithm(String algorithm)
throws IOException
{
if (algorithm.equals(MD5.getAlgorithm()))
{
return MD5;
}
if (algorithm.equals(SHA1.getAlgorithm()))
{
return SHA1;
}
throw new IOException("Unsupported digest algorithm!");
}
}