现在的位置: 首页 > 综合 > 正文

org.apache.commons.codec.binary.Base64 加密解密

2013年07月24日 ⁄ 综合 ⁄ 共 388字 ⁄ 字号 评论关闭
/**
     * 解密
     * 
     * @param pwd
     * @return
     * @see [类、类#方法、类#成员]
     */
    public static String decodeStr(String pwd)
    {
        Base64 base64 = new Base64();
        byte[] debytes = base64.decodeBase64(new String(pwd).getBytes());
        return new String(debytes);
    }

    /**
     * 加密
     * 
     * @param pwd
     * @return
     * @see [类、类#方法、类#成员]
     */
    public static String encodeStr(String pwd)
    {
        Base64 base64 = new Base64();
        byte[] enbytes = base64.encodeBase64Chunked(pwd.getBytes());
        return new String(enbytes);
    }

抱歉!评论已关闭.