本文整理汇总了Java中org.prcode.utility.basic.CharsetConstant类的典型用法代码示例。如果您正苦于以下问题:Java CharsetConstant类的具体用法?Java CharsetConstant怎么用?Java CharsetConstant使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CharsetConstant类属于org.prcode.utility.basic包,在下文中一共展示了CharsetConstant类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertToXml
import org.prcode.utility.basic.CharsetConstant; //导入依赖的package包/类
/**
* JavaBean转换成xml,默认编码UTF-8
*
* @param obj 待转换对象
* @return 转换后的xml
*/
public static String convertToXml(Object obj) {
String result = null;
try {
JAXBContext context = JAXBContext.newInstance(obj.getClass());
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.setProperty(Marshaller.JAXB_ENCODING, CharsetConstant.UTF_8);
StringWriter writer = new StringWriter();
marshaller.marshal(obj, writer);
result = writer.toString();
} catch (Exception e) {
logger.error(ExceptionUtil.parseException(e));
}
return result;
}
示例2: generationEncryptedData
import org.prcode.utility.basic.CharsetConstant; //导入依赖的package包/类
private static byte[] generationEncryptedData(String rawPass) throws Exception {
if (null == DKS || null == SECRET_KEY || null == CIPHER) {
return null;
}
SecureRandom secureRandom = new SecureRandom();
CIPHER.init(Cipher.ENCRYPT_MODE, SECRET_KEY, secureRandom);
return CIPHER.doFinal(rawPass.getBytes(CharsetConstant.UTF_8));
}
示例3: decrypt
import org.prcode.utility.basic.CharsetConstant; //导入依赖的package包/类
/**
*
* @title: decrypt
* @description: (对无盐值的密码进行解密, 返回解密后的原文)
* @param ciphertext 原文
* @return 解密后的字符
* @throws DESException
*/
public static String decrypt(String ciphertext) throws DESException {
try {
init();
byte[] generationDecryptData = generationDecryptData(ciphertext);
if (generationDecryptData == null) {
return null;
}
return new String(generationDecryptData, CharsetConstant.UTF_8);
} catch (Exception e) {
throw new DESException("DES use default slat decrypt exception", e);
}
}
示例4: generationDecryptData
import org.prcode.utility.basic.CharsetConstant; //导入依赖的package包/类
private static byte[] generationDecryptData(String ciphertext) throws Exception {
if (null == DKS || null == SECRET_KEY || null == CIPHER) {
return null;
}
SecureRandom secureRandom = new SecureRandom();
CIPHER.init(Cipher.DECRYPT_MODE, SECRET_KEY, secureRandom);
byte[] ciphertextByte = ciphertext.getBytes(CharsetConstant.UTF_8);
ciphertextByte = Base64.decodeBase64(ciphertextByte);
return CIPHER.doFinal(ciphertextByte);
}
示例5: decrypt
import org.prcode.utility.basic.CharsetConstant; //导入依赖的package包/类
/**
*
* @Title: decrypt
* @Description: (对无盐值的密码进行解密, 返回解密后的原文)
* @param ciphertext 原文
* @return 解密后的字符
* @throws DESException
*/
public static String decrypt(String ciphertext) throws DESException {
try {
init();
byte[] generationDecryptData = generationDecryptData(ciphertext);
if (generationDecryptData == null) {
return null;
}
return new String(generationDecryptData, CharsetConstant.UTF_8);
} catch (Exception e) {
throw new DESException("DES use default slat decrypt exception", e);
}
}