EN
Java - how to write own custom base64 util?
1
answers
5
points
Can someone help me to write custom base64 util in java?
Two basic methods:
- encode string
- decode string
Without using internal java core methods or external library like apache.
It should be as simple as possible. I would like to learn how to build simple base64.
Thank you.
1 answer
2
points
Check this article: https://dirask.com/posts/p59Jnp
Code from the article:
import java.util.Base64;
public class Example {
public static void main(String[] args) {
String text = "test123";
// encode
String encodedString = Base64.getEncoder().encodeToString(text.getBytes());
System.out.println(encodedString); // dGVzdDEyMw==
// decode
String decodedString = new String(Base64.getDecoder().decode(encodedString));
System.out.println(decodedString); // test123
}
}
0 comments
Add comment