All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.carlspring.commons.encryption.EncryptionAlgorithmsEnum Maven / Gradle / Ivy

There is a newer version: 1.1
Show newest version
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!");
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy