Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Trying to incrypt user password without a number or key being entered this is what I have and I am using Java. Program is to

Trying to incrypt user password without a number or key being entered this is what I have and I am using Java. Program is to get user input and verify that is meets criteria then encrypts password with a simple encryption (not to import a program that I have to encrypt)

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner s= new Scanner(System.in); System.out.print(" Enter the Password : "); String pass = s.next(); String PasswordManager pm = new PasswordManager(pass); // verify password //System.out.println(" Verify Password : "); System.out.println("Password Verification : "+pm.verifyPassword(pass)); // if(pm.verifyPassword(pass)) { System.out.println(" Encryption : "); System.out.println("Encrypted Password : "+pm.encrypt(pass)); } } } class PasswordManager{ private String password; public PasswordManager(String password){ this.password = password; } public String encrypt(String password) { String ans = ""; for(int i=0; i=8; //check if the input is greater than 8 characters boolean hasSpecial = !password.matches("[A-Za-z0-9]*"); // check if the input has a special characters boolean hasDigit = !password.matches(".*\\d+.*"); //check if the input contains a digit if(!isAtLeast8){ System.out.println("Your Password is not big enough please enter a password with minimun of 8 characters"); return true; }else if(!upperCase){ System.out.println("Password must contain at least one UPPERCASE letter"); return true; }else if(!lowerCase){ System.out.println("Password must contain at least one lower case letter"); return true; }else if(!hasSpecial){ System.out.println("Password must contain a special character"); return true; }else if(hasDigit){ System.out.println("Password must contain at least one number"); return true; }else{ System.out.println("Your password: "+password+", is valid"); return true; }

when finish running keep getting this error

Main.java:10: error: ';' expected String PasswordManager pm = new PasswordManager(pass); ^ 1 error

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions