加解密

    }
    
    /**
     * DES加密
* * @author : chenssy * @date : 2016年5月20日 下午5:39:46 * * @param value * 待加密字符 * @param key * 若key为空,则使用默认key * @return * 加密成功返回密文,否则返回null */ public static String desEncrypt(String value,String key){ key = key == null ? DESUtils.KEY : key; String result = null; try { if(value != null && !"".equals(value.trim())){ result = DESUtils.encrypt(value, key); } } catch (Exception e) { e.printStackTrace(); } return result; } /** * DES解密 * * @author : chenssy * @date : 2016年5月20日 下午5:55:56 * * @param value * 待解密字符 * @param key * 若key为空,则使用默认key * @return * @return */ public static String desDecrypt(String value,String key){ key = key == null ? DESUtils.KEY : key; String result = null; try { if(value != null && !"".equals(value.trim())){ result = DESUtils.decrypt(value, key); } } catch (Exception e) { e.printStackTrace(); } return result; } /** * AES加密 * * @author:chenssy * @date : 2016年5月21日 上午9:58:58 * * @param value * 待加密内容 * @param key * 秘钥 * @return */ public static String aesEncrypt(String value,String key ){ key = key == null ? AESUtils.KEY : key; String result = null; try { if(value != null && !"".equals(value.trim())){ //value is not null result = AESUtils.encrypt(value,key); } } catch (Exception e) { e.printStackTrace(); } return result; } /** * AES解密 * * @author:chenssy * @date : 2016年5月21日 上午10:02:07 * * @param value * 待解密内容 * @param key * 秘钥 * @return */ public static String aesDecrypt(String value , String key){ key = key == null ? AESUtils.KEY : key; String result = null; try { if(value != null && !"".equals(value.trim())){ //value is not null result = AESUtils.decrypt(value,key); } } catch (Exception e) { e.printStackTrace(); } return result;

你可能感兴趣的:(java)