Create a Java program to demonstrate the use of an interface for custom encryption
import java.util.Base64; interface Encryptor { String encrypt(String data); } public class Main { public static void main(String[] args) { Encryptor encryptor = data -> Base64.getEncoder().encodeToString(data.getBytes()); String originalData = "Hello World! 123"; String encryptedData = encryptor.encrypt(originalData); System.out.println("Original Data : " + originalData); System.out.println("Encrypted Data : " + encryptedData); } }
Original Data : Hello World! 123 Encrypted Data : SGVsbG8gV29ybGQhIDEyMw==
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions