MCPcopy Create free account
hub / github.com/f0ng/autoDecoder / base64ToHex

Method base64ToHex

src/com/autoDecoder/util/test.java:6–24  ·  view source on GitHub ↗
(String base64String)

Source from the content-addressed store, hash-verified

4
5 // Base64 编码的字符串转换为十六进制字符串
6 public static String base64ToHex(String base64String) {
7 // 解码 Base64 字符串得到原始字节数据
8 byte[] decodedBytes = Base64.getDecoder().decode(base64String);
9
10 // 使用 StringBuilder 存储结果
11 StringBuilder hexBuilder = new StringBuilder();
12
13 // 遍历字节数组,将每个字节转换为十六进制表示并拼接
14 for (byte decodedByte : decodedBytes) {
15 String hex = Integer.toHexString(0xff & decodedByte);
16 if (hex.length() == 1) {
17 hexBuilder.append('0'); // 如果是单个字符,前面补零
18 }
19 hexBuilder.append(hex);
20 }
21
22 // 返回最终的十六进制字符串
23 return hexBuilder.toString();
24 }
25
26 public static void main(String[] args) {
27 // Base64 编码的字符串示例

Callers 1

mainMethod · 0.95

Calls 1

decodeMethod · 0.80

Tested by

no test coverage detected