package com.xiaohe.mianshi1;
import java.io.IOException;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import Decoder.BASE64Decoder;
import Decoder.BASE64Encoder;
public class DesUtil {
private final static String DES = “DES”;
public static void main(String[] args) {
String data = "我爱你!!";
String key = "123116爱11";
System.out.println(enctypt(data, key));
System.out.println(decrypt(enctypt(data, key), key));
}
public static String enctypt(String data, String key) {
byte[] bt = encrypt(data.getBytes(), key.getBytes());
String strs = new BASE64Encoder().encode(bt);
return strs;
}
public static String decrypt(String data, String key) {
System.out.println("data++++" +