I'm making a program that will let you access a system via encrypted code from a USB. But I can't seem to figure out how I would go about making the user login to the computer via USB. I'll add the code in the code so far.
/*
This is a secure USB keycode app
Written by TheProgrammingPenguin
*/
//TODO: Make program that reads and writes encrypted code to/from USB
import java.util.*;
import java.sql.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
// Connect to a database
Connection con = DriverManager.getConnection(/*This will be the connection when the database is up*/);
public class startApp {
static int createKeycode() {
System.out.println("Enter your name:");
Scanner usersName = new Scanner(System.in);
System.out.print("Enter some random numbers");
Scanner numbers = new Scanner(System.in);
// Generate code
userCode = numbers;
// Create query to give to database
String query = "Update Users ** %d;" usersName;
String query1 = "Update userCodes %d ** %d" usersName, userCode;
con.executeQuery(query);
con.executeQuery(query1);
}
static int writeToUsb(userCode) {
// Encrypt code
int newUserCode = userCode * 500;
// Open file
file inputStream - new FileOutputStream("code.txt");
List<String> lines = text.readTextFile(inputStream);
// Add code to file
lines.add(newUserCode);
}
static int readFromUsb() {
// Get file path
path = file_path;
// Read file
FileReader readFromUsb = new FileReader(path);
// Verify the code through the database
int verify = readFromUsb.readAllLines();
int verification = verify / 500;
databaseVerify = con.executeQuery("SELECT ** from userCodes, %d;" verification);
if(databaseVerify.hasNextLine){
new login();
}
else {
System.out.println("Access denied.");
}
}
public static void main(String[] args) {
System.out.print("What would you like to do?");
Scanner userAction = new Scanner(System.in);
new starApp(userAction);
}
}