Encrypt and Decrypt in Java

前端 未结 7 1168
旧巷少年郎
旧巷少年郎 2020-12-01 08:24

I would like to store an encrypted password in a Java file. I saw at a solution using javax.crypto, but the problem with that was that the key was being ge

7条回答
  •  执念已碎
    2020-12-01 09:13

    public class GenerateEncryptedPassword {
    
        public static void main(String[] args){
    
            Scanner sc= new Scanner(System.in);    
            System.out.println("Please enter the password that needs to be encrypted :");
            String input = sc.next();
    
            try {
                String encryptedPassword= AESencrp.encrypt(input);
                System.out.println("Encrypted password generated is :"+encryptedPassword);
            } catch (Exception ex) {
                Logger.getLogger(GenerateEncryptedPassword.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
    

提交回复
热议问题