jodd.util.Base64.decode()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(3.1k)|赞(0)|评价(0)|浏览(281)

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

Base64.decode介绍

[英]Decodes a BASE64 encoded string.
[中]解码BASE64编码的字符串。

代码示例

代码示例来源:origin: redisson/redisson

public static String decodeToString(String s) {
  try {
    return new String(decode(s), JoddCore.encoding);
  } catch (UnsupportedEncodingException ignore) {
    return null;
  }
}

代码示例来源:origin: redisson/redisson

public static String decodeToString(byte[] arr) {
  try {
    return new String(decode(arr), JoddCore.encoding);
  } catch (UnsupportedEncodingException ignore) {
    return null;
  }
}

代码示例来源:origin: oblac/jodd

/**
 * Decodes the "Authorization" header and retrieves the
 * password from it. Returns <code>null</code> if the header is not present.
 */
public static String resolveAuthPassword(final HttpServletRequest request) {
  String header = request.getHeader(HEADER_AUTHORIZATION);
  if (header == null) {
    return null;
  }
  if (!header.contains("Basic ")) {
    return null;
  }
  final String encoded = header.substring(header.indexOf(' ') + 1);
  final String decoded = new String(Base64.decode(encoded));
  return decoded.substring(decoded.indexOf(':') + 1);
}

代码示例来源:origin: oblac/jodd

public static String decodeToString(final byte[] arr) {
  return StringUtil.newString(decode(arr));
}

代码示例来源:origin: oblac/jodd

/**
 * Decodes the "Authorization" header and retrieves the
 * user's name from it. Returns <code>null</code> if the header is not present.
 */
public static String resolveAuthUsername(final HttpServletRequest request) {
  String header = request.getHeader(HEADER_AUTHORIZATION);
  if (header == null) {
    return null;
  }
  if (!header.contains("Basic ")) {
    return null;
  }
  final String encoded = header.substring(header.indexOf(' ') + 1);
  final String decoded = new String(Base64.decode(encoded));
  return decoded.substring(0, decoded.indexOf(':'));
}

代码示例来源:origin: oblac/jodd

/**
 * Symmetrically decrypts the string.
 */
public String decrypt(String str) {
  try {
    str = StringUtil.replaceChar(str, ' ', '+');	// replace spaces with chars.
    byte[] dec = Base64.decode(str);    	// decode base64 to get bytes
    byte[] utf8 = dcipher.doFinal(dec);     // decrypt
    return new String(utf8, UTF_8);			// decode using utf-8
  } catch (Throwable ignore) {
    return null;
  }
}

代码示例来源:origin: oblac/jodd

public static String decodeToString(final String s) {
  return StringUtil.newString(decode(s));
}

代码示例来源:origin: oblac/jodd

@Test
  void testDecode_charArray() {
    final char[] input = enc.toCharArray();

    final byte[] actual_byteArray = Base64.decode(input);
    final String actual_string = new String(actual_byteArray);

    // asserts
    assertEquals(text, actual_string);
  }
}

代码示例来源:origin: org.jodd/jodd-core

/**
 * Symmetrically decrypts the string.
 */
public String decrypt(String str) {
  try {
    str = StringUtil.replaceChar(str, ' ', '+');	// replace spaces with chars.
    byte[] dec = Base64.decode(str);    	// decode base64 to get bytes
    byte[] utf8 = dcipher.doFinal(dec);     // decrypt
    return new String(utf8, UTF_8);			// decode using utf-8
  } catch (Throwable ignore) {
    return null;
  }
}

代码示例来源:origin: org.jodd/jodd-core

public static String decodeToString(final byte[] arr) {
  return StringUtil.newString(decode(arr));
}

代码示例来源:origin: org.jodd/jodd-core

public static String decodeToString(final String s) {
  return StringUtil.newString(decode(s));
}

相关文章