Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A common security method used for online banking is to ask the user for three ra

ID: 3581379 • Letter: A

Question

A common security method used for online banking is to ask the user for three random characters from a passcode. For example, if the passcode was 531278, they may ask for the 2nd, 3rd, and 5th characters; the expected reply would be: 317.

The text file, keylog.txt, contains fifty successful login attempts.

Given that the three characters are always asked for in order, analyse the file so as to determine the shortest possible secret passcode of unknown length.

The text file contains:

319
680
180
690
129
620
762
689
762
318
368
710
720
710
629
168
160
689
716
731
736
729
316
729
729
710
769
290
719
680
318
389
162
289
162
718
729
319
790
680
890
362
319
760
316
729
380
319
728
716

___I am trying to solve this problem this is what i have so far i dont know how to get it to work wondering if anyone could help me get this code working with this file that i have _____Answer is: 73162890

package jung;

import java.awt.Dimension;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Set;

import javax.swing.JFrame;

import edu.uci.ics.jung.algorithms.layout.CircleLayout;

import edu.uci.ics.jung.algorithms.layout.ISOMLayout;
import edu.uci.ics.jung.algorithms.layout.Layout;
import edu.uci.ics.jung.graph.DirectedSparseGraph;
import edu.uci.ics.jung.graph.Graph;
import edu.uci.ics.jung.graph.SparseGraph;
import edu.uci.ics.jung.visualization.BasicVisualizationServer;
import edu.uci.ics.jung.visualization.decorators.ToStringLabeller;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

public class BreadthFirstSearch {
  
public static String bfs(Graph g) {
StringBuilder b = new StringBuilder();

Queue q = new LinkedList();
Set visited = new HashSet();
Set found = new HashSet();

V start = (V) g.getVertices().toArray()[0];
q.offer(start);
found.add(start);

while (!q.isEmpty()) {
V vertex = q.poll(); //(we deque the first item from the queue)
//System.out.println(vertex);
for (V neighbor : g.getNeighbors(vertex)) {
if (!found.contains(neighbor) && !visited.contains(neighbor)) {
found.add(neighbor);
q.offer(neighbor);
}
}
b.append(vertex.toString() + " ");
visited.add(vertex); //(Purpose is to make sure that we dont double count any nodes or end
//up in an infinite loop. if we didnt do thi it would you would be readding stuff into the
//queue sp this prevents it.)
}

return b.toString();
}

public static void main(String[] args){
Graph g = new DirectedSparseGraph();
String ReadFileName = "keylog.txt";
try {
           Scanner file = new Scanner(new File(ReadFileName));
           while(file.hasNext()){
               String line = file.nextLine();
               String integerOne = (line.substring(0, 1));
String integerTwo = (line.substring(1, 2));
String integerThree = (line.substring(2, 3));
String integerFour = (line.substring(3, 4));
String integerFive = (line.substring(4, 5));
String integerSix = (line.substring(5, 6));
String integerSeven = (line.substring(6, 7));
String integerEight = (line.substring(7, 8));
String integerNine = (line.substring(8, 9));
           }
           file.close();
        }
       catch(FileNotFoundException e) {
           System.err.println("File not found");
       }
       // catch any other exception
       catch(Exception e) {
           e.printStackTrace();
       }


System.out.println();

Layout layout = new CircleLayout(g);
BasicVisualizationServer vv = new BasicVisualizationServer(layout);

vv.setPreferredSize(new Dimension(600, 600)); //Sets the viewing area size
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());

JFrame frame = new JFrame("Display Graph");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(vv);
frame.pack();
frame.setVisible(true);

}

Explanation / Answer

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class passcode {

static List resList = new ArrayList();

public static void main(String args[]) throws IOException {
BufferedReader sc = new BufferedReader(new FileReader(new File("keyslog.txt")));
String str = "";
while ((str = sc.readLine()) != null) {
char[] keysData = str.toCharArray();
int temp_index = 0;
int currentIndex = 0;
for (int index = 0; index < keysData.length; index++) {
temp_index = currentIndex;
if (currentIndex > 0 && temp_index >= currentIndex) {
resList.remove(currentIndex);
resList.add(currentIndex + 1, keysData[index]);
currentIndex++;
} else {
if (temp_index + 1 > resList.size()) {
resList.add(keysData[index]);
} else {
resList.add(temp_index + 1, keysData[index]);
}

temp_index += 1;
}
}
}

sc.close();

System.out.println(" The shortest possible secret passcode of unknown length" + resList.toString());
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote