敏感信息加密并做base64(卡号，手机号，cvn2,有效期）<br>
@param data 送 phoneNo,cvn2,有效期<br>
@param encoding<br>
@return 加密的密文<br>
774453
public static String encryptData(String data, String encoding) {
		return SecureUtil.encryptData(data, encoding, CertUtil
				.getEncryptCertPublicKey());
	}
731850
public static byte[] decode(String data) {
	// TODO: when we move to Java 8 change to
	// https://docs.oracle.com/javase/8/docs/api/java/util/Base64.Decoder.html
	return org.apache.commons.codec.binary.Base64.decodeBase64(data);
    }
401097
public static <T> T deserializeFromBase64(String data) {
        Objects.requireNonNull(data, Required.DATA.toString());
        
        byte[] bytes = base64Decoder.decode(data);
        return SerializationUtils.deserialize(bytes);
    }
341226
public static String encryptData(String data, String key) throws Exception {
		// 创建密码器
		Cipher cipher = Cipher.getInstance(ALGORITHM_MODE_PADDING);
		// 初始化
		cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(HashKit.md5(key).toLowerCase().getBytes(), ALGORITHM));
		return Base64Kit.encode(cipher.doFinal(data.getBytes()));
	}
727415
@Sensitive
    protected String decodeBasicAuth(String data, String encoding) {
        String output = "";
        byte decodedByte[] = null;
        decodedByte = Base64Coder.base64DecodeString(data);
        if (decodedByte != null && decodedByte.length > 0) {
            boolean decoded = false;
            if (encoding != null) {
                try {
                    output = new String(decodedByte, encoding);
                    decoded = true;
                } catch (Exception e) {
                    // fall back not to use encoding..
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "An exception is caught using the encoder: " + encoding + ". The exception is: " + e.getMessage());
                    }
                }
            }
            if (!decoded) {
                output = new String(decodedByte);
            }
        }
        return output;
    }
1091100
public static String encode(byte[] data) {
        if (data.length == 0) {
            return "";
        }
        final byte[] bytes = copyOfRange(data, 0, data.length);
        // Count leading zeroes.
        int zeroCount = 0;
        while (zeroCount < bytes.length && bytes[zeroCount] == 0) {
            ++zeroCount;
        }
        // The actual encoding.
        byte[] temp = new byte[bytes.length * 2];
        int j = temp.length;

        int startAt = zeroCount;
        while (startAt < bytes.length) {
            byte mod = divmod58(bytes, startAt);
            if (bytes[startAt] == 0) {
                ++startAt;
            }
            temp[--j] = (byte) ALPHABET[mod];
        }

        // Strip extra '1' if there are some after decoding.
        while (j < temp.length && temp[j] == ALPHABET[0]) {
            ++j;
        }
        // Add as many leading '1' as there were leading zeros.
        while (--zeroCount >= 0) {
            temp[--j] = (byte) ALPHABET[0];
        }

        byte[] output = copyOfRange(temp, j, temp.length);
        try {
            return new String(output, "US-ASCII");
        } catch (UnsupportedEncodingException e) {
            throw new ApplicationException(e);  // Cannot happen.
        }
    }
222273
public static byte[] decryptBase64AES(byte[] data, byte[] key) {
        try {
            return decryptAES(Base64.getDecoder().decode(data), key);
        } catch (Exception e) {
            return null;
        }
    }
1066069
private static String getEncodingToUse(String encoding)
    {
        //get encoding
        String updatedEncoding=encoding;
        if(updatedEncoding==null)
        {
            updatedEncoding=IOHelper.getDefaultEncoding();
        }
        
        return updatedEncoding;
    }
1166062
protected String decodeString(byte[] data) {
    String rv = null;
    try {
      if (data != null) {
        rv = new String(data, charset);
      }
    } catch (UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }
    return rv;
  }
539081
public static String encodeBase64(final byte[] data, final boolean chunked) {
        if (data != null && data.length > 0) {
            if (chunked) {
                return BASE64_CHUNKED_ENCODER.encodeToString(data).trim();
            }
            return BASE64_UNCHUNKED_ENCODER.encodeToString(data).trim();
        }
        return StringUtils.EMPTY;
    }
1020231
function(data, encoding) {
      if (encoding == null) {
        encoding = 'hex';
      }
      if (Array.isArray(data)) {
        return data;
      }
      switch (encoding) {
        case 'base64':
          return Gibberish.base64.decode(data);
        case 'hex':
          return Gibberish.h2a(data);
        case 'utf8':
          return Gibberish.s2a(data);
        default:
          throw new Error("Encoding not supported");
      }
    }
618832
protected String decode(byte[] bytes, String encoding) {

        try {
            return new String(bytes, encoding);
        } catch (UnsupportedEncodingException e) {
            return new String(bytes);
        }
    }
448851
public static byte[] encodeLZ(String data, String dictionary) {
    byte[] asBytes = new byte[0];
    try {
      asBytes = data.getBytes("UTF-8");
    } catch (UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }
    return encodeLZ(asBytes, dictionary);
  }
52070
public static String toBase64(Object o, String charset, String defaultValue) {
	;
	if (o instanceof byte[]) return toB64((byte[]) o, defaultValue);
	else if (o instanceof String) return toB64((String) o, charset, defaultValue);
	else if (o instanceof Number) return toB64(toString(((Number) o)), charset, defaultValue);
	else if (o instanceof ObjectWrap) {
	    return toBase64(((ObjectWrap) o).getEmbededObject(defaultValue), charset, defaultValue);
	}
	else if (o == null) {
	    return toBase64("", charset, defaultValue);
	}
	else {
	    byte[] b = toBinary(o, null);
	    if (b != null) return toB64(b, defaultValue);
	    else {
		String str = toString(o, null);
		if (str != null) return toBase64(str, charset, defaultValue);
		else return defaultValue;
	    }
	}
    }
1289592
public static List<String> decodeStringsFromBase64Parameter(String data) {

        data = StringUtils.replaceChars(data, BASE64_EXTRA_REPLACEMENTS, BASE64_EXTRA);
        byte[] bytes = deobfuscateBytes(Base64.decodeBase64(data));
        try {
            JSONArray json = new JSONArray(new String(bytes, "UTF-8"));
            List<String> result = Lists.newArrayList();
            for (int i = 0; i < json.length(); i++) {
                result.add(json.getString(i));
            }
            return result;
        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (JSONException e) {
            throw new IllegalArgumentException("Decoding failed: " + data, e);
        }
        return null;
    }
167355
private String decode(byte[] data, String encoding) {

        try {
            return new String(data, encoding);
        } catch (UnsupportedEncodingException e) {
            LOG.warn(e.getLocalizedMessage(), e);
            return new String(data);
        }
    }
953268
@Override
    public String encode(final String data, final Optional<RegisteredService> service) {
        try {
            if (service.isPresent()) {
                val registeredService = service.get();
                val publicKey = createRegisteredServicePublicKey(registeredService);
                val result = encodeInternal(data, publicKey, registeredService);
                if (result != null) {
                    return EncodingUtils.encodeBase64(result);
                }
            }
        } catch (final Exception e) {
            LOGGER.warn(e.getMessage(), e);
        }
        return null;
    }