0% found this document useful (0 votes)
13 views14 pages

aditya_exceed[1]

The document outlines a project for a Password Locker App developed in Java, which securely manages user passwords through functionalities like adding, retrieving, deleting, and listing passwords. It employs a HashMap for storage and a simple Caesar Cipher for encryption. The implementation details include step-by-step instructions, code snippets, and suggestions for future enhancements such as stronger encryption and a graphical user interface.

Uploaded by

borugaddaaditya5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views14 pages

aditya_exceed[1]

The document outlines a project for a Password Locker App developed in Java, which securely manages user passwords through functionalities like adding, retrieving, deleting, and listing passwords. It employs a HashMap for storage and a simple Caesar Cipher for encryption. The implementation details include step-by-step instructions, code snippets, and suggestions for future enhancements such as stronger encryption and a graphical user interface.

Uploaded by

borugaddaaditya5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Idea Title: PASSWORD LOCKER APP USING JAVA.

Course Name and Code: Essentials of Innovation (ACSD03)


Student Name: Borugadda Aditya Vardhan
Roll Number: 24951A6608
Class: I Semester, CSE(AI&ML)
Section: A
Date of Examination: 04-02-2025

Faculty Signature:
Index :
Introduction
Features of the App
Technologies Used
Step-by-Step Implementation
conclusion

Introduction:
A password locker app helps users manage their passwords by securely
storing them in an encrypted format. The app will have functionalities such
as adding, viewing, editing, and deleting password entries.

Password Locker App in Java


Features of the App
Add a new password: Users can store a new password for a specific account
or service.

Retrieve a password: Users can retrieve a stored password by providing the


account name.

Delete a password: Users can delete a stored password.

List all accounts: Users can view all the accounts for which passwords are
stored.

Encryption: Passwords will be encrypted before storing to ensure security.

Technologies Used
Java Programming Language

Java Collections (HashMap) for storing passwords

Basic encryption using Caesar Cipher (for demonstration purposes)

Step-by-Step Implementation
1. Setting Up the Project
Create a new Java project in your preferred IDE (e.g., IntelliJ IDEA, Eclipse).
Create a class named PasswordLockerApp.

2. Data Structure for Storing Passwords


We will use a HashMap to store passwords. The key will be the account name
(e.g., "Gmail"), and the value will be the encrypted password.

java
Copy
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class PasswordLockerApp {


private static Map<String, String> passwordMap = new HashMap<>();
private static final int ENCRYPTION_KEY = 3; // Key for Caesar Cipher
private static Scanner scanner = new Scanner(System.in);

public static void main(String[] args) {


while (true) {
System.out.println("\nPassword Locker App");
System.out.println("1. Add Password");
System.out.println("2. Retrieve Password");
System.out.println("3. Delete Password");
System.out.println("4. List All Accounts");
System.out.println("5. Exit");
System.out.print("Choose an option: ");
int choice = scanner.nextInt();
scanner.nextLine(); // Consume newline

switch (choice) {
case 1:
addPassword();
break;
case 2:
retrievePassword();
break;
case 3:
deletePassword();
break;
case 4:
listAllAccounts();
break;
case 5:
System.out.println("Exiting...");
return;
default:
System.out.println("Invalid choice. Please try again.");
}
}
}
}
3. Adding a Password
To add a password, we will encrypt it using a simple Caesar Cipher before
storing it in the HashMap.

java
Copy
private static void addPassword() {
System.out.print("Enter account name: ");
String account = scanner.nextLine();
System.out.print("Enter password: ");
String password = scanner.nextLine();

// Encrypt the password


String encryptedPassword = encrypt(password);
passwordMap.put(account, encryptedPassword);
System.out.println("Password added successfully!");
}

private static String encrypt(String password) {


StringBuilder encrypted = new StringBuilder();
for (char c : password.toCharArray()) {
if (Character.isLetter(c)) {
char base = Character.isLowerCase(c) ? 'a' : 'A';
encrypted.append((char) (base + (c - base + ENCRYPTION_KEY) % 26));
} else {
encrypted.append(c);
}
}
return encrypted.toString();
}
4. Retrieving a Password
To retrieve a password, the user will provide the account name. The app will decrypt the password
and display it.

java

Copy

private static void retrievePassword() {

System.out.print("Enter account name: ");

String account = scanner.nextLine();

if (passwordMap.containsKey(account)) {

String encryptedPassword = passwordMap.get(account);

String decryptedPassword = decrypt(encryptedPassword);

System.out.println("Password for " + account + " is: " + decryptedPassword);

} else {

System.out.println("Account not found!");

}
private static String decrypt(String encryptedPassword) {

StringBuilder decrypted = new StringBuilder();

for (char c : encryptedPassword.toCharArray()) {

if (Character.isLetter(c)) {

char base = Character.isLowerCase(c) ? 'a' : 'A';

decrypted.append((char) (base + (c - base - ENCRYPTION_KEY + 26) % 26));

} else {

decrypted.append(c);

return decrypted.toString();

5. Deleting a Password

To delete a password, the user will provide the account name, and the app will remove the entry
from the HashMap.

java

Copy

private static void deletePassword() {

System.out.print("Enter account name: ");

String account = scanner.nextLine();

if (passwordMap.containsKey(account)) {

passwordMap.remove(account);

System.out.println("Password for " + account + " deleted successfully!");

} else {

System.out.println("Account not found!");

6. Listing All Accounts

The app will display all the account names for which passwords are stored.
java

Copy

private static void listAllAccounts() {

if (passwordMap.isEmpty()) {

System.out.println("No accounts found!");

} else {

System.out.println("Stored Accounts:");

for (String account : passwordMap.keySet()) {

System.out.println("- " + account);

7. Running the App

Compile and run the PasswordLockerApp class. The app will display a menu for the user to interact
with.

Explanation of the Code

HashMap for Storage: The HashMap is used to store account names and encrypted passwords. It
provides fast lookups and easy management of key-value pairs.

Encryption and Decryption: The Caesar Cipher is used for basic encryption. Each character in the
password is shifted by a fixed number (the encryption key). For example, 'a' becomes 'd' with a key
of 3.

User Interaction: The app uses a Scanner to take input from the user and a switch statement to
handle different options.

Security Note: The Caesar Cipher is used here for simplicity. In a real-world application, you should
use stronger encryption algorithms like AES.

Full Code

java
Copy

import java.util.HashMap;

import java.util.Map;

import java.util.Scanner;

public class PasswordLockerApp {

private static Map<String, String> passwordMap = new HashMap<>();

private static final int ENCRYPTION_KEY = 3; // Key for Caesar Cipher

private static Scanner scanner = new Scanner(System.in);

public static void main(String[] args) {

while (true) {

System.out.println("\nPassword Locker App");

System.out.println("1. Add Password");

System.out.println("2. Retrieve Password");

System.out.println("3. Delete Password");

System.out.println("4. List All Accounts");

System.out.println("5. Exit");

System.out.print("Choose an option: ");

int choice = scanner.nextInt();

scanner.nextLine(); // Consume newline

switch (choice) {

case 1:

addPassword();

break;

case 2:

retrievePassword();

break;

case 3:

deletePassword();
break;

case 4:

listAllAccounts();

break;

case 5:

System.out.println("Exiting...");

return;

default:

System.out.println("Invalid choice. Please try again.");

private static void addPassword() {

System.out.print("Enter account name: ");

String account = scanner.nextLine();

System.out.print("Enter password: ");

String password = scanner.nextLine();

// Encrypt the password

String encryptedPassword = encrypt(password);

passwordMap.put(account, encryptedPassword);

System.out.println("Password added successfully!");

private static void retrievePassword() {

System.out.print("Enter account name: ");

String account = scanner.nextLine();

if (passwordMap.containsKey(account)) {

String encryptedPassword = passwordMap.get(account);


String decryptedPassword = decrypt(encryptedPassword);

System.out.println("Password for " + account + " is: " + decryptedPassword);

} else {

System.out.println("Account not found!");

private static void deletePassword() {

System.out.print("Enter account name: ");

String account = scanner.nextLine();

if (passwordMap.containsKey(account)) {

passwordMap.remove(account);

System.out.println("Password for " + account + " deleted successfully!");

} else {

System.out.println("Account not found!");

private static void listAllAccounts() {

if (passwordMap.isEmpty()) {

System.out.println("No accounts found!");

} else {

System.out.println("Stored Accounts:");

for (String account : passwordMap.keySet()) {

System.out.println("- " + account);

private static String encrypt(String password) {


StringBuilder encrypted = new StringBuilder();

for (char c : password.toCharArray()) {

if (Character.isLetter(c)) {

char base = Character.isLowerCase(c) ? 'a' : 'A';

encrypted.append((char) (base + (c - base + ENCRYPTION_KEY) % 26));

} else {

encrypted.append(c);

return encrypted.toString();

private static String decrypt(String encryptedPassword) {

StringBuilder decrypted = new StringBuilder();

for (char c : encryptedPassword.toCharArray()) {

if (Character.isLetter(c)) {

char base = Character.isLowerCase(c) ? 'a' : 'A';

decrypted.append((char) (base + (c - base - ENCRYPTION_KEY + 26) % 26));

} else {

decrypted.append(c);

return decrypted.toString();

Conclusion

This password locker app is a simple yet effective way to manage passwords securely. It
demonstrates the use of Java collections, basic encryption, and user interaction. You can enhance
this app by adding features like saving data to a file, using stronger encryption, or adding a
graphical user interface (GUI).

You might also like