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


Java CharsetConstant类代码示例

本文整理汇总了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;
}
 
开发者ID:DomKing,项目名称:springbootWeb,代码行数:24,代码来源:JaxbXMLUtil.java

示例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));
}
 
开发者ID:DomKing,项目名称:springbootWeb,代码行数:10,代码来源:PropertyDESUtil.java

示例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);
    }
}
 
开发者ID:DomKing,项目名称:springbootWeb,代码行数:21,代码来源:PropertyDESUtil.java

示例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);
}
 
开发者ID:DomKing,项目名称:springbootWeb,代码行数:12,代码来源:PropertyDESUtil.java

示例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);
    }
}
 
开发者ID:DomKing,项目名称:server-utility,代码行数:21,代码来源:PropertyDESUtil.java


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