![]() |
|
[Java] Convert String to Base64 - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: Java, JVM, & JRE (https://sinister.ly/Forum-Java-JVM-JRE) +--- Thread: [Java] Convert String to Base64 (/Thread-Java-Convert-String-to-Base64) Pages:
1
2
|
[Java] Convert String to Base64 - Mr.Kurd - 04-02-2018 In The Name Of Allah
Al-Salam Alekum
Hey guys, Converting text(String) to Base64 in Java:
Code: JTextField text = new JTextField();
JFrame Converter = new JFrame("String to Base64");
String love = "Sinister.ly";
String s = Base64.getEncoder().encodeToString(love.getBytes("utf-8"));
Converter.add(text);
text.setText(s);
Converter.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Converter.show();
Converter.setSize(300, 100);![]() Wa Salam Alekum
RE: [Java] Convert String to Base64 - Blink - 04-02-2018 You could just do Code: echo "string" | base64It's a pretty bad idea to use Java for stuff like this, since Java has a huge runtime that gives a ton of overhead. You're better off using C, or even assembly Also, GUI is completely unneeded. But hey, it works as a decent example program. RE: [Java] Convert String to Base64 - mothered - 04-02-2018 Or you can simply use crypo.com Either way, thanks for the contribution. RE: [Java] Convert String to Base64 - Nytelife26 - 04-02-2018 And then you have Python: Code: import base64
base64.b64encode(bytes("String here", "utf-8"))RE: [Java] Convert String to Base64 - Mr.Kurd - 04-03-2018 Guys it is just for learning how Java do that, about the GUI was for windows users who don't use CMD tho. Thank you
RE: [Java] Convert String to Base64 - mothered - 04-03-2018 (04-03-2018, 08:19 AM)Mr.Kurd Wrote: Guys it is just for learning how Java do that And rightly so. You've documented and Illustrated It very well. I've just simply offered an alternative. RE: [Java] Convert String to Base64 - Mr.Kurd - 04-03-2018 (04-03-2018, 08:53 AM)mothered Wrote:(04-03-2018, 08:19 AM)Mr.Kurd Wrote: Guys it is just for learning how Java do that Thank you about a website I like this one: https://www.base64encode.org/ RE: [Java] Convert String to Base64 - mothered - 04-03-2018 (04-03-2018, 09:00 AM)Mr.Kurd Wrote:(04-03-2018, 08:53 AM)mothered Wrote:(04-03-2018, 08:19 AM)Mr.Kurd Wrote: Guys it is just for learning how Java do that I haven't come across this site. Bookmarked, thank you. RE: [Java] Convert String to Base64 - Bish0pQ - 04-03-2018 Thanks man! Will be usefull for some people that are interested in doing this in their application. Also the others say there are easier ways to do this, you're all correct, but I don't think he was trying to show how to encode a string to base64, but more specifically, how to do it in a Java application, so people can use it in their application if they need it. Thank you for sharing this. RE: [Java] Convert String to Base64 - Mr.Kurd - 04-03-2018 (04-03-2018, 11:12 AM)Bish0pQ Wrote: Thanks man! Will be usefull for some people that are interested in doing this in their application. Thank you my friend, you got it. |