sun.misc.BASE64Decoder Java Examples

The following examples show how to use sun.misc.BASE64Decoder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RSAUtils.java    From rhizobia_J with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @Description: 取得私钥
 * @Param: keyFile 私钥文件路径(pem格式)
 *         部分PEM文件的头尾不是"-----BEGIN PRIVATE KEY-----\n"
 * @return: PrivateKey 私钥
 */
public PrivateKey getPrivateKey(String keyFile) throws Exception {
    File f = new File(keyFile);
    FileInputStream fis = new FileInputStream(f);
    DataInputStream dis = new DataInputStream(fis);
    byte[] keyBytes = new byte[(int) f.length()];
    dis.readFully(keyBytes);
    dis.close();

    String temp = new String(keyBytes);
    String privKeyPEM = temp.replace(pemPriHead, "");
    privKeyPEM = privKeyPEM.replace(pemPriEnd, "");

    byte[] decoded = new BASE64Decoder().decodeBuffer(privKeyPEM);

    PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(decoded);
    KeyFactory kf = KeyFactory.getInstance(keyAlgorithm);
    return kf.generatePrivate(spec);
}
 
Example #2
Source File: StandaloneArgument.java    From argument-reasoning-comprehension-task with Apache License 2.0 6 votes vote down vote up
public JCas getJCas()
        throws RuntimeException
{
    if (base64JCas == null) {
        return null;
    }

    try {
        byte[] bytes = new BASE64Decoder()
                .decodeBuffer(new ByteArrayInputStream(base64JCas.getBytes("utf-8")));
        JCas jCas = JCasFactory.createJCas();
        XmiCasDeserializer.deserialize(new ByteArrayInputStream(bytes), jCas.getCas());

        return jCas;
    }
    catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #3
Source File: Des.java    From hy.common.base with Apache License 2.0 6 votes vote down vote up
/**
 * 获取解密之后的信息
 * 
 * @param str
 * @return
 */
public String decrypt(String str) 
{
    // 基于BASE64编码,接收byte[]并转换成String
    BASE64Decoder base64decoder = new BASE64Decoder();
    try {
        // 将字符串decode成byte[]
        byte[] bytes = base64decoder.decodeBuffer(str);
        // 获取解密对象
        Cipher cipher = Cipher.getInstance($ALGORITHM);
        // 初始化解密信息
        cipher.init(Cipher.DECRYPT_MODE, this.key);
        // 解密
        byte[] doFinal = cipher.doFinal(bytes);
        // 返回解密之后的信息
        return new String(doFinal, $CHARSETNAME);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #4
Source File: Uploader.java    From jeewx-boot with Apache License 2.0 6 votes vote down vote up
/**
 * 接受并保存以base64格式上传的文件
 * @param fieldName
 */
public void uploadBase64(String fieldName){
	String savePath = this.getFolder(this.savePath);
	String base64Data = this.request.getParameter(fieldName);
	this.fileName = this.getName("test.png");
	this.url = savePath + "/" + this.fileName;
	BASE64Decoder decoder = new BASE64Decoder();
	try {
		File outFile = new File(this.getPhysicalPath(this.url));
		OutputStream ro = new FileOutputStream(outFile);
		byte[] b = decoder.decodeBuffer(base64Data);
		for (int i = 0; i < b.length; ++i) {
			if (b[i] < 0) {
				b[i] += 256;
			}
		}
		ro.write(b);
		ro.flush();
		ro.close();
		this.state=this.errorInfo.get("SUCCESS");
	} catch (Exception e) {
		this.state = this.errorInfo.get("IO");
	}
}
 
Example #5
Source File: ImageUtils.java    From classchecks with Apache License 2.0 6 votes vote down vote up
/**
 * 对字节数组字符串进行Base64解码并生成图片
 * @param base64	 图像的Base64编码字符串
 * @param fileSavePath	图像要保存的地址
 * @return
 */
public static boolean convertBase64ToImage(String base64, String fileSavePath) {
	if(base64 == null) return false;
	
	BASE64Decoder decoder = new BASE64Decoder();
	
	// Base64解码
	try {
		byte[] buffer = decoder.decodeBuffer(base64);
		for(int i = 0; i < buffer.length; i ++) {
			if(buffer[i] < 0) {
				buffer[i] += 256;
			}
		}
		// 生成JPEG图片
		OutputStream out = new FileOutputStream(fileSavePath);
		out.write(buffer);
		out.flush();
		out.close();
		return true;
	} catch (IOException e) {
		e.printStackTrace();
	}
	return false;
}
 
Example #6
Source File: Base64Utils.java    From jeewx-boot with Apache License 2.0 6 votes vote down vote up
public static MultipartFile base64ToMultipart(String base64) {
    try {
        String[] baseStr = base64.split(",");

        BASE64Decoder decoder = new BASE64Decoder();
        byte[] b = new byte[0];
        b = decoder.decodeBuffer(baseStr[1]);

        for(int i = 0; i < b.length; ++i) {
            if (b[i] < 0) {
                b[i] += 256;
            }
        }
        return new Base64DecodeMultipartFile(b, baseStr[0]);
    } catch (IOException e) {
        return null;
    }
}
 
Example #7
Source File: Base64ImgUtils.java    From spring-boot with Apache License 2.0 6 votes vote down vote up
/**
 * base64字符串转化成图片,对字节数组字符串进行Base64解码并生成图片
 * @param base64String 返回Base64编码过的字节数组字符串
 * @param outImgFilePath 图片文件路径
 * @return true 成功
 * */
public static final boolean toImage(String base64String, String outImgFilePath) {
    if(StringUtils.isEmpty(base64String)) return false;
    BASE64Decoder decoder = new BASE64Decoder();
    try
    {
        //Base64解码
        byte[] b = decoder.decodeBuffer(base64String);
        for(int i=0;i<b.length;++i)
        {
            if(b[i]<0)
            {//调整异常数据
                b[i]+=256;
            }
        }
        //生成jpeg图片
        OutputStream out = new FileOutputStream(outImgFilePath);
        out.write(b);
        out.flush();
        out.close();
        return true;
    } catch (IOException e) {
        System.err.println("base64字符串转化成byte数组:" + e.getMessage());
    }
    return false;
}
 
Example #8
Source File: Uploader.java    From jeewx-boot with Apache License 2.0 6 votes vote down vote up
/**
 * 接受并保存以base64格式上传的文件
 * @param fieldName
 */
public void uploadBase64(String fieldName){
	String savePath = this.getFolder(this.savePath);
	String base64Data = this.request.getParameter(fieldName);
	this.fileName = this.getName("test.png");
	this.url = savePath + "/" + this.fileName;
	BASE64Decoder decoder = new BASE64Decoder();
	try {
		File outFile = new File(this.getPhysicalPath(this.url));
		OutputStream ro = new FileOutputStream(outFile);
		byte[] b = decoder.decodeBuffer(base64Data);
		for (int i = 0; i < b.length; ++i) {
			if (b[i] < 0) {
				b[i] += 256;
			}
		}
		ro.write(b);
		ro.flush();
		ro.close();
		this.state=this.errorInfo.get("SUCCESS");
	} catch (Exception e) {
		this.state = this.errorInfo.get("IO");
	}
}
 
Example #9
Source File: Base64URL.java    From tls-sig-api-v2-java with MIT License 6 votes vote down vote up
public static byte[] base64DecodeUrl(byte[] input) throws IOException {
    byte[] base64 = input.clone();
    for (int i = 0; i < base64.length; ++i)
        switch (base64[i]) {
            case '*':
                base64[i] = '+';
                break;
            case '-':
                base64[i] = '/';
                break;
            case '_':
                base64[i] = '=';
                break;
            default:
                break;
        }
    return new BASE64Decoder().decodeBuffer(base64.toString());
}
 
Example #10
Source File: BaofooRsaReadUtil.java    From aaden-pay with Apache License 2.0 6 votes vote down vote up
/**
 * 根据公钥Cer文本串读取公钥
 * 
 * @param pubKeyText
 * @return
 */
public static PublicKey getPublicKeyByText(String pubKeyText) {
	try {
		CertificateFactory certificateFactory = CertificateFactory.getInstance(BaofooRsaConst.KEY_X509);
		BufferedReader br = new BufferedReader(new StringReader(pubKeyText));
		String line = null;
		StringBuilder keyBuffer = new StringBuilder();
		while ((line = br.readLine()) != null) {
			if (!line.startsWith("-")) {
				keyBuffer.append(line);
			}
		}
		Certificate certificate = certificateFactory.generateCertificate(new ByteArrayInputStream(new BASE64Decoder().decodeBuffer(keyBuffer.toString())));
		return certificate.getPublicKey();
	} catch (Exception e) {
		// log.error("解析公钥内容失败:", e);
	}
	return null;
}
 
Example #11
Source File: RSAUtils.java    From rhizobia_J with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @Description: 取得公钥
 * @Param: keyFile 公钥文件路径(pem格式)
 * @return: PublicKey 公钥
 */
public PublicKey getPublicKey(String keyFile) throws Exception {
    File f = new File(keyFile);
    FileInputStream fis = new FileInputStream(f);
    DataInputStream dis = new DataInputStream(fis);
    byte[] keyBytes = new byte[(int) f.length()];
    dis.readFully(keyBytes);
    dis.close();

    String temp = new String(keyBytes);
    String publicKeyPEM = temp.replace(pemPubHead, "");
    publicKeyPEM = publicKeyPEM.replace(pemPubEnd, "");

    byte[] decoded = new BASE64Decoder().decodeBuffer(publicKeyPEM);

    X509EncodedKeySpec spec = new X509EncodedKeySpec(decoded);
    KeyFactory kf = KeyFactory.getInstance(keyAlgorithm);
    return kf.generatePublic(spec);
}
 
Example #12
Source File: ECDSAUtils.java    From rhizobia_J with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @Description: 取得私钥
 * @Param: keyFile 私钥文件路径(pem格式)
 *         部分PEM文件的头尾不是"-----BEGIN PRIVATE KEY-----\n"
 * @return: PrivateKey 私钥
 */
public PrivateKey getPrivateKey(String keyFile) throws Exception {
    File f = new File(keyFile);
    FileInputStream fis = new FileInputStream(f);
    DataInputStream dis = new DataInputStream(fis);
    byte[] keyBytes = new byte[(int) f.length()];
    dis.readFully(keyBytes);
    dis.close();

    String temp = new String(keyBytes);
    String privKeyPEM = temp.replace(pemPriHead, "");
    privKeyPEM = privKeyPEM.replace(pemPriEnd, "");

    byte[] decoded = new BASE64Decoder().decodeBuffer(privKeyPEM);

    PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(decoded);
    KeyFactory kf = KeyFactory.getInstance("EC");
    return kf.generatePrivate(spec);
}
 
Example #13
Source File: ECDSAUtils.java    From rhizobia_J with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @Description: 取得公钥
 * @Param: keyFile 公钥文件路径(pem格式)
 * @return: PublicKey 公钥
 */
public PublicKey getPublicKey(String keyFile) throws Exception {
    File f = new File(keyFile);
    FileInputStream fis = new FileInputStream(f);
    DataInputStream dis = new DataInputStream(fis);
    byte[] keyBytes = new byte[(int) f.length()];
    dis.readFully(keyBytes);
    dis.close();

    String temp = new String(keyBytes);
    String publicKeyPEM = temp.replace(pemPubHead, "");
    publicKeyPEM = publicKeyPEM.replace(pemPubEnd, "");

    byte[] decoded = new BASE64Decoder().decodeBuffer(publicKeyPEM);

    X509EncodedKeySpec spec = new X509EncodedKeySpec(decoded);
    KeyFactory kf = KeyFactory.getInstance("EC");
    return kf.generatePublic(spec);
}
 
Example #14
Source File: ImageUtils.java    From wechat-pay-sdk with MIT License 6 votes vote down vote up
/**
 * <pre>
 * Base64编码的字符解码为图片
 *
 * </pre>
 *
 * @param imageString
 * @return
 */
public static BufferedImage decodeToImage(String imageString) {

    BufferedImage image = null;
    byte[] imageByte;
    try {
        BASE64Decoder decoder = new BASE64Decoder();
        imageByte = decoder.decodeBuffer(imageString);
        ByteArrayInputStream bis = new ByteArrayInputStream(imageByte);
        image = ImageIO.read(bis);
        bis.close();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return image;
}
 
Example #15
Source File: CryptoAES.java    From hauth-java with MIT License 6 votes vote down vote up
/**
 * AES加密字符串
 *
 * @param content 需要被加密的字符串
 * @return 密文
 */
public static String aesDecrypt(String content) {
    try {

        byte[] encrypted1 = new BASE64Decoder().decodeBuffer(content);

        Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
        SecretKeySpec keyspec = new SecretKeySpec(PASSWORD_KEY.getBytes(), "AES");
        IvParameterSpec ivspec = new IvParameterSpec(PASSWORD_KEY.getBytes());

        cipher.init(Cipher.DECRYPT_MODE, keyspec, ivspec);

        String originalString = new String(cipher.doFinal(encrypted1));
        int length = originalString.length();
        int ch = originalString.charAt(length - 1);
        return originalString.substring(0, length - ch);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
 
Example #16
Source File: DESUtil.java    From Project with Apache License 2.0 6 votes vote down vote up
/**
 * 获取解密之后的信息
 * 
 * @param str 待解密字符串
 * @return
 */
public static String getDecryptString(String str) {
	// 基于BASE64编码,接收byte[]并转换为String
	BASE64Decoder base64decoder = new BASE64Decoder();
	try {
		// 将字符串decode成byte[]
		byte[] bytes = base64decoder.decodeBuffer(str);
		// 获取解密对象
		Cipher cipher = Cipher.getInstance(ALGORITHM);
		// 初始化解密信息
		cipher.init(Cipher.DECRYPT_MODE, key);
		// 解密
		byte[] doFinal = cipher.doFinal(bytes);
		// 返回解密之后的信息
		return new String(doFinal, CHARSETNAME);
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
Example #17
Source File: DESUtil.java    From SDIMS with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 获取解密后信息
 * @param str
 * @return
 */
public static String getDecryptString(String str){
	
	BASE64Decoder base64Decoder=new BASE64Decoder();
	try{
		//将字符串decode成byte[]
		byte[] decodeBuffer = base64Decoder.decodeBuffer(str);
		//获取解密对象
		Cipher cipher=Cipher.getInstance(ALGORITHM);
		cipher.init(Cipher.DECRYPT_MODE, key);
		//解密
		byte[] doFinal = cipher.doFinal(decodeBuffer);
		//返回解密后的信息
		return new String(doFinal, CHARSETNAME);
	}catch(Exception e){
		throw new RuntimeException(e);
	} finally {
	}
}
 
Example #18
Source File: WXPayClient.java    From springboot-pay-example with Apache License 2.0 6 votes vote down vote up
/**
 * 解密退款通知
 *
 * <a href="https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_16&index=11>退款结果通知文档</a>
 * @return
 * @throws Exception
 */
public Map<String, String> decodeRefundNotify(HttpServletRequest request) throws Exception {
    // 从request的流中获取参数
    Map<String, String> notifyMap = this.getNotifyParameter(request);
    log.info(notifyMap.toString());

    String reqInfo = notifyMap.get("req_info");
    //(1)对加密串A做base64解码,得到加密串B
    byte[] bytes = new BASE64Decoder().decodeBuffer(reqInfo);

    //(2)对商户key做md5,得到32位小写key* ( key设置路径:微信商户平台(pay.weixin.qq.com)-->账户设置-->API安全-->密钥设置 )
    Cipher cipher = Cipher.getInstance(ALGORITHM_MODE_PADDING);
    SecretKeySpec key = new SecretKeySpec(WXPayUtil.MD5(config.getKey()).toLowerCase().getBytes(), ALGORITHM);
    cipher.init(Cipher.DECRYPT_MODE, key);

    //(3)用key*对加密串B做AES-256-ECB解密(PKCS7Padding)
    // java.security.InvalidKeyException: Illegal key size or default parameters
    // https://www.cnblogs.com/yaks/p/5608358.html
    String responseXml = new String(cipher.doFinal(bytes),"UTF-8");
    Map<String, String> responseMap = WXPayUtil.xmlToMap(responseXml);
    return responseMap;
}
 
Example #19
Source File: ResponseProcessUtils.java    From ais-sdk with Apache License 2.0 5 votes vote down vote up
/**
 * 处理返回Base64编码的图像文件的生成
 * 
 * @param response
 * @throws UnsupportedOperationException
 * @throws IOException
 */
public static void processResponseWithImage(HttpResponse response, String fileName) throws UnsupportedOperationException, IOException {
	String result = HttpClientUtils.convertStreamToString(response.getEntity().getContent());
	JSONObject resp = JSON.parseObject(result);
	JSONObject responseRlt = (JSONObject) resp.get("result");
	String imageString = (String)responseRlt.get("data");
	
	byte[] fileBytes = new BASE64Decoder().decodeBuffer(imageString);
	writeBytesToFile(fileName, fileBytes);
}
 
Example #20
Source File: FtpClient.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private byte[] getSecurityData() {
    String s = getLastResponseString();
    if (s.substring(4, 9).equalsIgnoreCase("ADAT=")) {
        BASE64Decoder decoder = new BASE64Decoder();
        try {
            // Need to get rid of the leading '315 ADAT='
            // and the trailing newline
            return decoder.decodeBuffer(s.substring(9, s.length() - 1));
        } catch (IOException e) {
            //
        }
    }
    return null;
}
 
Example #21
Source File: ResponseProcessUtils.java    From ais-sdk with Apache License 2.0 5 votes vote down vote up
/**
 * 处理返回Base64编码的图像文件的生成
 * 
 * @param response
 * @throws UnsupportedOperationException
 * @throws IOException
 */
public static void processResponseWithImage(HttpResponse response, String fileName) throws UnsupportedOperationException, IOException {
	String result = HttpClientUtils.convertStreamToString(response.getEntity().getContent());
	JSONObject resp = JSON.parseObject(result);
	String imageString = (String)resp.get("result");
	byte[] fileBytes =  new BASE64Decoder().decodeBuffer(imageString);
	writeBytesToFile(fileName, fileBytes);
}
 
Example #22
Source File: LianlianBase64.java    From aaden-pay with Apache License 2.0 5 votes vote down vote up
public static String getFromBASE64(String s) {
	if (s == null)
		return null;

	BASE64Decoder decoder = new BASE64Decoder();
	try {
		byte[] b = decoder.decodeBuffer(s);
		return new String(b, "UTF-8");
	} catch (Exception e) {
		return null;
	}
}
 
Example #23
Source File: Base64Util.java    From PoseidonX with Apache License 2.0 5 votes vote down vote up
public static String decode(String s) {
    if (s == null)
        return null;
    BASE64Decoder decoder = new BASE64Decoder();
    try {
        byte[] b = decoder.decodeBuffer(s);
        return new String(b,"UTF-8");
    } catch (Exception e) {
        return null;
    }
}
 
Example #24
Source File: LocalUploadServiceImpl.java    From mysiteforme with Apache License 2.0 5 votes vote down vote up
@Override
public String uploadBase64(String base64) {
    StringBuffer webUrl=new StringBuffer("/static/upload/");
    BASE64Decoder decoder = new BASE64Decoder();
    try
    {
        //Base64解码
        byte[] b = decoder.decodeBuffer(base64);
        for(int i=0;i<b.length;++i)
        {
            if(b[i]<0)
            {//调整异常数据
                b[i]+=256;
            }
        }
        //生成jpeg图片
        StringBuffer ss = new StringBuffer(ResourceUtils.getURL("classpath:").getPath());
        String filePath = ss.append("static/upload/").toString();
        File targetFileDir = new File(filePath);
        if(!targetFileDir.exists()){
            targetFileDir.mkdirs();
        }
        StringBuffer sb = new StringBuffer(filePath);
        StringBuffer fileName = new StringBuffer(RandomUtil.randomUUID());
        sb.append(fileName);
        sb.append(".jpg");
        String imgFilePath = sb.toString();//新生成的图片
        OutputStream out = new FileOutputStream(imgFilePath);
        out.write(b);
        out.flush();
        out.close();
        return webUrl.append(sb).toString();
    }
    catch (Exception e)
    {
        return null;
    }
}
 
Example #25
Source File: Tools.java    From Jantent with MIT License 5 votes vote down vote up
public static String deAes(String data, String key) throws Exception {
    Cipher cipher = Cipher.getInstance("AES");
    SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
    cipher.init(Cipher.DECRYPT_MODE, secretKeySpec);
    byte[] cipherTextBytes = new BASE64Decoder().decodeBuffer(data);
    byte[] decValue = cipher.doFinal(cipherTextBytes);
    return new String(decValue);
}
 
Example #26
Source File: FtpClient.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private byte[] getSecurityData() {
    String s = getLastResponseString();
    if (s.substring(4, 9).equalsIgnoreCase("ADAT=")) {
        BASE64Decoder decoder = new BASE64Decoder();
        try {
            // Need to get rid of the leading '315 ADAT='
            // and the trailing newline
            return decoder.decodeBuffer(s.substring(9, s.length() - 1));
        } catch (IOException e) {
            //
        }
    }
    return null;
}
 
Example #27
Source File: HTTPBasicAuthorizeFilter.java    From easy-sync with Apache License 2.0 5 votes vote down vote up
private String getFromBASE64(String s) {    
    if (s == null)    
        return null;    
    BASE64Decoder decoder = new BASE64Decoder();    
    try {    
        byte[] b = decoder.decodeBuffer(s);    
        return new String(b);    
    } catch (Exception e) {    
        return null;    
    }    
}
 
Example #28
Source File: SecureUtil.java    From DataM with Apache License 2.0 5 votes vote down vote up
/**
 * Description 根据键值进行解密
 */
public static String decrypt(String data, String key) throws IOException,
        Exception {
    if (data == null)
        return null;
    BASE64Decoder decoder = new BASE64Decoder();
    byte[] buf = decoder.decodeBuffer(data);
    byte[] bt = decrypt(buf, key.getBytes(ENCODE));
    return new String(bt, ENCODE);
}
 
Example #29
Source File: HttpAesUtil.java    From paascloud-master with Apache License 2.0 5 votes vote down vote up
/**
 * 解密
 *
 * @param contentParam 需要加密的内容
 * @param keyParam     加密密码
 * @param md5Key       是否对key进行md5加密
 * @param ivParam      加密向量
 *
 * @return string
 */
public static String decrypt(String contentParam, String keyParam, boolean md5Key, String ivParam) {
	try {
		if (PubUtils.isNull(contentParam, keyParam, md5Key, ivParam)) {
			return "";
		}
		byte[] content = new BASE64Decoder().decodeBuffer(contentParam);
		byte[] key = keyParam.getBytes(CHAR_SET);
		byte[] iv = ivParam.getBytes(CHAR_SET);

		if (md5Key) {
			MessageDigest md = MessageDigest.getInstance("MD5");
			key = md.digest(key);
		}
		SecretKeySpec skeySpec = new SecretKeySpec(key, "AES");
		//"算法/模式/补码方式"
		Cipher cipher = Cipher.getInstance("AES/CBC/ISO10126Padding");
		//使用CBC模式, 需要一个向量iv, 可增加加密算法的强度
		IvParameterSpec ivps = new IvParameterSpec(iv);
		cipher.init(Cipher.DECRYPT_MODE, skeySpec, ivps);
		byte[] bytes = cipher.doFinal(content);
		return new String(bytes, CHAR_SET);
	} catch (Exception ex) {
		log.error("解密密码失败", ex);
		throw new HttpAesException("解密失败");
	}
}
 
Example #30
Source File: SecureUtil.java    From DataM with Apache License 2.0 5 votes vote down vote up
/**
 * 使用 默认key 解密
 */
public static String decrypt(String data) throws IOException, Exception {
    if (data == null)
        return null;
    BASE64Decoder decoder = new BASE64Decoder();
    byte[] buf = decoder.decodeBuffer(data);
    byte[] bt = decrypt(buf, defaultKey.getBytes(ENCODE));
    return new String(bt, ENCODE);
}