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:
xxxxxxxxxx
1
import java.util.Base64;
2
3
public class Example {
4
5
public static void main(String[] args) {
6
7
String text = "test123";
8
9
// encode
10
String encodedString = Base64.getEncoder().encodeToString(text.getBytes());
11
System.out.println(encodedString); // dGVzdDEyMw==
12
13
// decode
14
String decodedString = new String(Base64.getDecoder().decode(encodedString));
15
System.out.println(decodedString); // test123
16
}
17
}
0 commentsShow commentsAdd comment