Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


[Java] Convert String to Base64 filter_list
Author
Message
[Java] Convert String to Base64 #1
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);


[Image: p_822j27rj1.png]

Wa Salam Alekum
Die  But Don't Lie
“Oh Abu Dharr! Don’t look at the smallness of the sin but look at the one you disobeyed.” Prophet Muhammad (pbuh)
[Image: p_237m2jx1.png]
Click for Free VPN

[+] 1 user Likes Mr.Kurd's post
Reply

RE: [Java] Convert String to Base64 #2
You could just do
Code:
echo "string" | base64

It'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.
(This post was last modified: 04-02-2018, 08:26 AM by Blink.)


(11-02-2018, 02:51 AM)Skullmeat Wrote: Ok, there no real practical reason for doing this, but that's never stopped me.

Reply

RE: [Java] Convert String to Base64 #3
Or you can simply use crypo.com

Either way, thanks for the contribution.
[Image: AD83g1A.png]

Reply

RE: [Java] Convert String to Base64 #4
And then you have Python:
Code:
import base64
base64.b64encode(bytes("String here", "utf-8"))
~ Nytelife26 ~

Reply

RE: [Java] Convert String to Base64 #5
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 Smile
Die  But Don't Lie
“Oh Abu Dharr! Don’t look at the smallness of the sin but look at the one you disobeyed.” Prophet Muhammad (pbuh)
[Image: p_237m2jx1.png]
Click for Free VPN

Reply

RE: [Java] Convert String to Base64 #6
(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.
[Image: AD83g1A.png]

Reply

RE: [Java] Convert String to Base64 #7
(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

And rightly so. You've documented and Illustrated It very well.

I've just simply offered an alternative.

Thank you about a website I like this one:
https://www.base64encode.org/
Die  But Don't Lie
“Oh Abu Dharr! Don’t look at the smallness of the sin but look at the one you disobeyed.” Prophet Muhammad (pbuh)
[Image: p_237m2jx1.png]
Click for Free VPN

Reply

RE: [Java] Convert String to Base64 #8
(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

And rightly so. You've documented and Illustrated It very well.

I've just simply offered an alternative.

Thank you about a website I like this one:
https://www.base64encode.org/

I haven't come across this site.

Bookmarked, thank you.
[Image: AD83g1A.png]

[+] 1 user Likes mothered's post
Reply

RE: [Java] Convert String to Base64 #9
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.
~~ Might be back? ~~

Reply

RE: [Java] Convert String to Base64 #10
(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.

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.

Thank you my friend, you got it.
Die  But Don't Lie
“Oh Abu Dharr! Don’t look at the smallness of the sin but look at the one you disobeyed.” Prophet Muhammad (pbuh)
[Image: p_237m2jx1.png]
Click for Free VPN

Reply







Users browsing this thread: 1 Guest(s)