Red Security
[Java] Convert String to Base64 - Printable Version

+- Red Security (https://redsecurity.info/cc)
+-- Forum: Programming (https://redsecurity.info/cc/forumdisplay.php?fid=5)
+--- Forum: Java (https://redsecurity.info/cc/forumdisplay.php?fid=7)
+--- Thread: [Java] Convert String to Base64 (/showthread.php?tid=482)



[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 = "Red Security";
       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