[英]How to convert a "binary string" to base64?
I've followed this: https:\/\/dev.twitter.com\/docs\/auth\/creating-signature<\/a>我遵循了这个:
https<\/a> :\/\/dev.twitter.com\/docs\/auth\/creating-signature
Tried this:
http:\/\/www.motobit.com\/util\/base64-decoder-encoder.asp<\/a>试过这个:
http<\/a> :\/\/www.motobit.com\/util\/base64-decoder-encoder.asp
http:\/\/www.hash-cracker.com\/base64.php#anchor<\/a>
http:\/\/www.hash-cracker.com\/base64.php#anchor<\/a>
http:\/\/www.opinionatedgeek.com\/dotnet\/tools\/Base64Encode\/<\/a>
http:\/\/www.opinionatedgeek.com\/dotnet\/tools\/Base64Encode\/<\/a>
and none give that string.没有人给出那个字符串。
The problem of using those online tools isn't going to be in the base64 conversion - it's going to be parsing the hex string into a byte array to start with. 使用这些在线工具的问题不会在base64转换中 - 它将把十六进制字符串解析为字节数组开始。 In your real code that won't be a problem, as it'll be the output of another stage.
在你真正的代码中,这将不是一个问题,因为它将是另一个阶段的输出。 Just to prove that, here's some sample Java code, using a public domain base64 encoder :
为了证明这一点,这里有一些示例Java代码,使用公共域base64编码器 :
public class Test {
public static void main(String[] args) throws Exception {
byte[] data = { (byte) 0xB6, (byte) 0x79, (byte) 0xC0, (byte) 0xAF,
(byte) 0x18, (byte) 0xF4, (byte) 0xE9, (byte) 0xC5,
(byte) 0x87, (byte) 0xAB, (byte) 0x8E, (byte) 0x20,
(byte) 0x0A, (byte) 0xCD, (byte) 0x4E, (byte) 0x48,
(byte) 0xA9, (byte) 0x3F, (byte) 0x8C, (byte) 0xB6 };
String text = Base64.encodeBytes(data);
System.out.println(text);
}
}
Output: tnnArxj06cWHq44gCs1OSKk/jLY= 输出:tnnArxj06cWHq44gCs1OSKk / jLY =
您可以使用此链接将二进制字符串转换为 Base64 https://cryptii.com/pipes/binary-to-text
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.