[英]Can I decode data with base64 in php which was encoded in java?
I have this java code I used to encode a serialized object that contains a couple of strings in base64 我有这个Java代码,我曾经用来编码一个序列化的对象,该对象在base64中包含几个字符串
public static String encode(Object obj) throws IOException {
ByteArrayOutputStream b = new ByteArrayOutputStream();
ObjectOutputStream o = new ObjectOutputStream(b);
o.writeObject(obj);
return Base64.encodeToString(b.toByteArray(), Base64.DEFAULT);
}
I store the resultant string in database using PHP ... I know how to decode this in java but for some reasons I need to do it in the PHP code ... so how to do it in PHP ? 我使用PHP将结果字符串存储在数据库中...我知道如何在Java中对其进行解码,但是由于某些原因,我需要在PHP代码中进行编码...因此如何在PHP中进行处理?
Base64 is an encoding scheme, so it doesn't matter which language you use when you encode or decode. Base64是一种编码方案,因此在编码或解码时使用哪种语言都没有关系。
<?php
$str = 'VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==';//your base64 encoded string
echo base64_decode($str);
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.