I have a base64 encoded string.
"jZsq4NNN0K4HzssoDEakhImknSVHLWpsmIF2AEBNacLykXJWBK9VKmCuuX1SR5iMNlfqXe7/eP8oLFEZp50E3g=="
When I trying decode with php (base64_decode
)
Result: ��*��M��(F�����%G-jl��v@Mi��rV�U*
��}RG��6W�]��x�(,Q���`
When I trying with javascript (window.atob
)
Result: *àÓMЮÎË(F¤¤%G-jlv@MiÂòrV¯U*
®¹}RG6Wê]îÿxÿ(,Q§Þ"`
Now we came strange part.
Now I trying with JDK 1.8.0_201 (Base64.getDecoder().decode
)
Result: [B@4e25154f
Now with JDK 1.8.0_66
Result: [B@2a139a55
Lets try with latest JDK (10.0.1),
Result: [B@6073f712
As you can see, different results in every version. I don't know why and I want to learn.
Edit:
public static void main(String[] args)
{
String version = System.getProperty("java.version");
System.out.print(version + " || " + decodeMeee());
}
private static String decodeMeee() {
return newBase64.getDecoder().decode("jZsq4NNN0K4HzssoDEakhImknSVHLWpsmIF2AEBNacLykXJWBK9VKmCuuX1SR5iMNlfqXe7/eP8oLFEZp50E3g==");
}
And now I tried same thing with converting manually. It seems go with the grain.
public static void main(String[] args)
{
String version = System.getProperty("java.version");
System.out.print(version + " || " + decodeMeee());
}
private static String decodeMeee() {
return new String(Base64.getDecoder().decode("jZsq4NNN0K4HzssoDEakhImknSVHLWpsmIF2AEBNacLykXJWBK9VKmCuuX1SR5iMNlfqXe7/eP8oLFEZp50E3g=="));
}