1

I have this java code I used to encode a serialized object that contains a couple of strings in 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 ?

1

1 Answer 1

1

Base64 is an encoding scheme, so it doesn't matter which language you use when you encode or decode.

 <?php
    $str = 'VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==';//your base64 encoded string
    echo base64_decode($str);
 ?>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.