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

com.tukeof.common.util.CryptoUtil Maven / Gradle / Ivy

The newest version!
package com.tukeof.common.util;

import com.tukeof.common.crypto.CipherEnum;

/**
 * Create by tuke on 2019-02-19
 */
public class CryptoUtil {

    public static String encryptDES(String input, String key) {
        return encryptDES(input.getBytes(), key);
    }

    public static String encryptDES(byte[] input, String key) {
        try {
            byte[] output = CipherEnum.DES.encryptCbc(input, key.getBytes());
            return Base64Util.encodeBase64ToString(output);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public static String decryptDES(String input, String key) {
        return decryptDES(input.getBytes(), key);
    }

    public static String decryptDES(byte[] input, String key) {
        try {
            byte[] output = CipherEnum.DES.encryptCbc(input, key.getBytes());
            return Base64Util.encodeBase64ToString(output);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy