😁 Base 64 Example: In this example, we are going to learn about How to encrypt a password and decodes the password in the java program language. With this article, we will understand What is encoding and decoding in java with the Base64 class. import java.util.Scanner; import java.util.Base64; class Test { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("Enter Password"); String password=sc.next(); System.out.println("Encode password: "+encode(password)); String encode=encode(password); System.out.println("Decode Password: "+decode(encode)); } //Encode: public static String encode(String input) { return Base64.getEncoder().encodeToString(input.getBytes()); } //Decode: public static String decode(String input) { byte[] decodedBytes = Base64.getDecoder().decode(input); return new String(decodedBytes); } }
Success of Your life.These website will provides the latest technology and also provide the development of programming logic. computer science branch this website is very important. Every day practice code and developed the logic.