16 진수 값을 Base64로 변환하고 실패한 몇 가지 예제를 웹을 통해 분석하려고했습니다. 16 진수에서 16 진수로 변환
http://tomeko.net/online_tools/hex_to_base64.php?lang=en
은 내가 AWS 객체와 구글 클라우드 스토리지 MD5 값의 ETAG 값을 비교해야합니다.base64(eTag)=GCS_MD5
.
eTag:6a95b4dd5419f2ffb9f655309c931cb0
및
MD5:apW03VQZ8v+59lUwnJMcsA==
16 진수를 Base64로 변환하려면 어떻게해야합니까?
나는 stack-overflow에서 다양한 예제를 시도했지만 여전히 그렇게 할 수 없었다.
public static void main(String[] args) throws IOException {
String hexadecimal = "6a95b4dd5419f2ffb9f655309c931cb0";
System.out.println("hexadecimal: " + hexadecimal);
String binaryNum = hexToBin(hexadecimal);
System.out.println("" + binaryNum + ", length:" + binaryNum.length());
byte[] encoded = Base64.encodeBase64(binaryNum.getBytes());
byte[] decoded = Base64.decodeBase64(binaryNum.getBytes());
System.out.println("encoded: " + Base64.isBase64(encoded));
System.out.println("decoded: " + Base64.isBase64(decoded));
System.out.println(Arrays.toString(encoded));
String encodedString = new String(encoded);
System.out.println(binaryNum + " = " + encodedString);
String decodedString = new String(decoded);
System.out.println(binaryNum + " = " + decodedString);
System.out.println("ByteEncoding::" + base64Encode(binaryNum.getBytes()));
System.out.println("ByteDecoding::" + base64Decode(binaryNum));
}