当前位置: 首页>>代码示例>>Java>>正文


Java BASE64Decoder类代码示例

本文整理汇总了Java中sun.misc.BASE64Decoder的典型用法代码示例。如果您正苦于以下问题:Java BASE64Decoder类的具体用法?Java BASE64Decoder怎么用?Java BASE64Decoder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BASE64Decoder类属于sun.misc包,在下文中一共展示了BASE64Decoder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: aesDecrypt

import sun.misc.BASE64Decoder; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:hzwy23,项目名称:hauth-java,代码行数:27,代码来源:CryptoAES.java

示例2: decodeToImage

import sun.misc.BASE64Decoder; //导入依赖的package包/类
/**
 * <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;
}
 
开发者ID:arccode,项目名称:wechat-pay-sdk,代码行数:25,代码来源:ImageUtils.java

示例3: desEncrypt

import sun.misc.BASE64Decoder; //导入依赖的package包/类
public static String desEncrypt(String data){
    try
    {
   	 if(data==null||data.equals("")){
   		 return "";
   	 }
   	 data=data.trim();
        byte[] encrypted1 = new BASE64Decoder().decodeBuffer(data);
         
        Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
        SecretKeySpec keyspec = new SecretKeySpec(ZFMPWD.getBytes(), "AES");
        IvParameterSpec ivspec = new IvParameterSpec(iv.getBytes());
         
        cipher.init(Cipher.DECRYPT_MODE, keyspec, ivspec);

        byte[] original = cipher.doFinal(encrypted1);
        String originalString = new String(original);
        return originalString.trim();
    }
    catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:liuxuanhai,项目名称:WeiXing_xmu-2016-MrCode,代码行数:25,代码来源:Aes.java

示例4: invokeFunction

import sun.misc.BASE64Decoder; //导入依赖的package包/类
public InvokeFunctionResponse invokeFunction(InvokeFunctionRequest request)
    throws ClientException, ServerException {
    HttpResponse response = client.doAction(request, CONTENT_TYPE_APPLICATION_STREAM, "POST");
    InvokeFunctionResponse invokeFunctionResponse = new InvokeFunctionResponse();
    invokeFunctionResponse.setContent(response.getContent());
    invokeFunctionResponse.setPayload(response.getContent());

    invokeFunctionResponse.setHeader(response.getHeaders());
    invokeFunctionResponse.setStatus(response.getStatus());
    Map<String, String> headers = response.getHeaders();
    if (headers != null && headers.containsKey(HeaderKeys.INVOCATION_LOG_RESULT)) {
        try {
            String logResult = new String(new BASE64Decoder().decodeBuffer(headers.get(HeaderKeys.INVOCATION_LOG_RESULT)));
            invokeFunctionResponse.setLogResult(logResult);
        } catch (IOException e) {
            throw new ClientException(e);
        }
    }
    return invokeFunctionResponse;
}
 
开发者ID:aliyun,项目名称:fc-java-sdk,代码行数:21,代码来源:FunctionComputeClient.java

示例5: getPublicKeyByText

import sun.misc.BASE64Decoder; //导入依赖的package包/类
/**
 * 根据公钥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;
}
 
开发者ID:yi-jun,项目名称:aaden-pay,代码行数:25,代码来源:BaofooRsaReadUtil.java

示例6: generateImage

import sun.misc.BASE64Decoder; //导入依赖的package包/类
private static void generateImage(String imgStr,String path,String newFileName,String ext){
	if (imgStr != null) {
		int p = imgStr.indexOf(",");
		String head = imgStr.substring(0, p);
		String datas = imgStr.substring(p + 1);
		System.out.println("FULL-Path:" + path + "\\" + newFileName + "." + ext);
		BASE64Decoder decoder = new BASE64Decoder();
		try {
			// 解密
			byte[] b = decoder.decodeBuffer(datas);
			// 处理数据
			for (int i = 0; i < b.length; ++i) {
				if (b[i] < 0) {
					b[i] += 256;
				}
			}
			OutputStream out1 = new FileOutputStream(path + "\\" + newFileName + "." + ext);
			out1.write(b);
			out1.flush();
			out1.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:lrxzl,项目名称:djpt,代码行数:26,代码来源:MyBase64.java

示例7: get3DESDecrypt

import sun.misc.BASE64Decoder; //导入依赖的package包/类
/**
 * 3-DES解密
 *
 * @param String
 *          src 要进行3-DES解密的String
 * @param String
 *          spkey分配的SPKEY
 * @return String 3-DES加密后的String
 */

public static String get3DESDecrypt(String src, String spkey) {
  String requestValue = "";
  try {

    // 得到3-DES的密钥匙

    // URLDecoder.decodeTML控制码进行转义的过程
    String URLValue = getURLDecoderdecode(src);

    // 进行3-DES加密后的内容进行BASE64编码

    BASE64Decoder base64Decode = new BASE64Decoder();
    byte[] base64DValue = base64Decode.decodeBuffer(URLValue);

    // 要进行3-DES加密的内容在进行/"UTF-16LE/"取字节

    requestValue = deCrypt(base64DValue, spkey);
  } catch (Exception e) {
    e.printStackTrace();
  }
  return requestValue;
}
 
开发者ID:Lingzh0ng,项目名称:ITSM,代码行数:33,代码来源:Endecrypt.java

示例8: generateImage

import sun.misc.BASE64Decoder; //导入依赖的package包/类
/**
 * 对字节数组字符串进行Base64解码并生成图片
 * @param imgStr            转换为图片的字符串
 * @param imgCreatePath     将64编码生成图片的路径
 * @return
 */
public static boolean generateImage(String imgStr, String imgCreatePath){
    if (imgStr == null) //图像数据为空
        return false;
    BASE64Decoder decoder = new BASE64Decoder();
    try {
    	//Base64解码
        byte[] b = decoder.decodeBuffer(imgStr);
        for(int i=0;i<b.length;++i) {
            if(b[i] < 0) {//调整异常数据
                b[i] += 256;
            }
        }
        OutputStream out = new FileOutputStream(imgCreatePath);    
        out.write(b);
        out.flush();
        out.close();
        return true;
    } catch (Exception e){
        return false;
    }
}
 
开发者ID:Fetax,项目名称:Fetax-AI,代码行数:28,代码来源:ImageAnd64Binary.java

示例9: getJCas

import sun.misc.BASE64Decoder; //导入依赖的package包/类
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);
    }
}
 
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:20,代码来源:StandaloneArgument.java

示例10: getFromTokenStr

import sun.misc.BASE64Decoder; //导入依赖的package包/类
public void getFromTokenStr(String tokenStr) {
    byte[] b;
    String result;
    if (tokenStr != null) {
        BASE64Decoder decoder = new BASE64Decoder();
        try {
            b = decoder.decodeBuffer(URLDecoder.decode(tokenStr,"utf-8"));
            result = new String(b, "utf-8");
            String[] list = result.split("::");
            this.userId = list[0];
            this.username = list[1];
            String lo = list[2];
            this.startTime = Long.valueOf(lo);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:haibodong,项目名称:JSiter,代码行数:19,代码来源:Token.java

示例11: decodeBase64

import sun.misc.BASE64Decoder; //导入依赖的package包/类
public static String decodeBase64(String s) {
    if (s == null) {
        return null;
    }
    byte[] b;
    String result = null;
    if (s != null) {
        BASE64Decoder decoder = new BASE64Decoder();
        try {
            b = decoder.decodeBuffer(s);
            result = new String(b, "UTF-8");
        } catch (Exception e) {
            return null;
        }
    }
    return result;
}
 
开发者ID:baohongfei,项目名称:think-in-java,代码行数:18,代码来源:Base64Util.java

示例12: convertBase64ToImage

import sun.misc.BASE64Decoder; //导入依赖的package包/类
/**
 * 对字节数组字符串进行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;
}
 
开发者ID:IaHehe,项目名称:classchecks,代码行数:31,代码来源:ImageUtils.java

示例13: desencriptar

import sun.misc.BASE64Decoder; //导入依赖的package包/类
public static String desencriptar(String passPhrase, String str)
    throws InvalidKeySpecException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException, IOException, IllegalBlockSizeException, BadPaddingException
{
    Cipher ecipher = null;
    Cipher dcipher = null;
    java.security.spec.KeySpec keySpec = new PBEKeySpec(passPhrase.toCharArray(), SALT_BYTES, ITERATION_COUNT);
    SecretKey key = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(keySpec);
    ecipher = Cipher.getInstance(key.getAlgorithm());
    dcipher = Cipher.getInstance(key.getAlgorithm());
    java.security.spec.AlgorithmParameterSpec paramSpec = new PBEParameterSpec(SALT_BYTES, ITERATION_COUNT);
    ecipher.init(1, key, paramSpec);
    dcipher.init(2, key, paramSpec);
    byte dec[] = (new BASE64Decoder()).decodeBuffer(str);
    byte utf8[] = dcipher.doFinal(dec);
    return new String(utf8, "UTF8");
}
 
开发者ID:marlonalexis,项目名称:Multicentro_Mascotas,代码行数:17,代码来源:UtilCryptography.java

示例14: decrypt

import sun.misc.BASE64Decoder; //导入依赖的package包/类
/**
* 解密
* @param src byte[]
* @param password String
* @return String
* @throws Exception
*/
public static String decrypt(String decodeStr, String password) throws Exception {
	byte[] str=new BASE64Decoder().decodeBuffer(decodeStr);
	// DES算法要求有一个可信任的随机数源
	SecureRandom random = new SecureRandom();
	// 创建一个DESKeySpec对象
	DESKeySpec desKey = new DESKeySpec(password.getBytes());
	// 创建一个密匙工厂
	SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
	// 将DESKeySpec对象转换成SecretKey对象
	SecretKey securekey = keyFactory.generateSecret(desKey);
	// Cipher对象实际完成解密操作
	Cipher cipher = Cipher.getInstance("DES");
	// 用密匙初始化Cipher对象
	cipher.init(Cipher.DECRYPT_MODE, securekey, random);
	// 真正开始解密操作
	byte[] passByte=cipher.doFinal(str);
	return new String(passByte);
}
 
开发者ID:noseparte,项目名称:Spring-Boot-Server,代码行数:26,代码来源:DES.java

示例15: AESDecryptor

import sun.misc.BASE64Decoder; //导入依赖的package包/类
public AESDecryptor() {
    try
    {
        /* Derive the key, given password and salt. */
        SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
        KeySpec spec;

        spec = new PBEKeySpec(Constants.FRAMEWORK_NAME.toCharArray(), SALT, ITERATIONS, KEY_SIZE);
        SecretKey tmp = factory.generateSecret(spec);
        secret = new SecretKeySpec(tmp.getEncoded(), "AES");

        // CBC = Cipher Block chaining
        // PKCS5Padding Indicates that the keys are padded
        cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");

        // For production use commons base64 encoder
        base64Decoder = new BASE64Decoder();
    }
    catch (Exception e)
    {
        throw new RuntimeException("Unable to initialize AESDecryptor", e);
    }
}
 
开发者ID:networknt,项目名称:light-4j,代码行数:24,代码来源:AESDecryptor.java


注:本文中的sun.misc.BASE64Decoder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。