PHP JAVA BASE64 encode decode

版权声明:原创文章欢迎转载,不过要记得加出处哦 https://blog.csdn.net/wljk506/article/details/84626287

注意所有编码都是 UTF8 编码
JAVA 1.8 +
JAVA 11 +
风.foxwho

java Base64 encoder

String tmp = "A1234好.123~!@#$%^*&(";
System.out.println(tmp);
System.out.println(Base64.getEncoder().encodeToString(tmp.getBytes())); 
输出:
QTEyMzTlpb0uMTIzfiFAIyQlXiomKA==

php base64 encode

$str = "A1234好.123~!@#$%^*&(";
echo base64_encode($str);
输出:
QTEyMzTlpb0uMTIzfiFAIyQlXiomKA==

java base64 decode

 String tmp2 = "QTEyMzTlpb0uMTIzfiFAIyQlXiomKA==";
 String result = "";
 try {
     result = new String(Base64.getDecoder().decode(tmp2), "UTF-8");
 } catch (Exception $e) {

 }
 // A1234好.123~!@#$%^*&(
 System.out.println(result);
 结果:
 A1234好.123~!@#$%^*&(

php base64 decode

$str = "QTEyMzTlpb0uMTIzfiFAIyQlXiomKA==";
echo base64_decode($str);
结果:
A1234.123~!@#$%^*&(
阅读更多

扫码向博主提问

风.foxwho

非学,无以致疑;非问,无以广识
  • 擅长领域:
  • php
  • java
  • go
  • 架构
  • more
去开通我的Chat快问

没有更多推荐了,返回首页