org.apache.commons.codec.binary.Base64.isInAlphabet()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(1.3k)|赞(0)|评价(0)|浏览(103)

本文整理了Java中org.apache.commons.codec.binary.Base64.isInAlphabet()方法的一些代码示例,展示了Base64.isInAlphabet()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Base64.isInAlphabet()方法的具体详情如下:
包路径:org.apache.commons.codec.binary.Base64
类名称:Base64
方法名:isInAlphabet

Base64.isInAlphabet介绍

[英]Returns whether or not the octet is in the Base64 alphabet.
[中]返回octet是否在Base64字母表中。

代码示例

代码示例来源:origin: NemProject/nem.core

/**
 * Converts a string to a byte array.
 *
 * @param base64String The input Base64 string.
 * @return The output byte array.
 */
public static byte[] getBytes(final String base64String) {
  final Base64 codec = new Base64();
  final byte[] encodedBytes = StringEncoder.getBytes(base64String);
  if (!codec.isInAlphabet(encodedBytes, true)) {
    throw new IllegalArgumentException("malformed base64 string passed to getBytes");
  }
  return codec.decode(encodedBytes);
}

代码示例来源:origin: nemtech/nem2-sdk-java

/**
 * Converts a string to a byte array.
 *
 * @param base64String The input Base64 string.
 * @return The output byte array.
 */
public static byte[] getBytes(final String base64String) {
  final Base64 codec = new Base64();
  final byte[] encodedBytes = StringEncoder.getBytes(base64String);
  if (!codec.isInAlphabet(encodedBytes, true)) {
    throw new IllegalArgumentException("malformed base64 string passed to getBytes");
  }
  return codec.decode(encodedBytes);
}

相关文章