Advertisement
Guest User

Untitled

a guest
Aug 27th, 2020
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. package sas.kacper.itemsapp;
  2.  
  3. import java.lang.Boolean;
  4. import java.lang.String;
  5.  
  6. import java.io.FileReader;
  7. import java.io.IOException;
  8. import java.io.BufferedReader;
  9. import java.io.FileNotFoundException;
  10.  
  11. public class LoginAuthenticator {
  12.    
  13.     public static Boolean checkLogin(String Login, String hashPass) {
  14.        
  15.         BufferedReader strFile = null;
  16.        
  17.         try {
  18.             strFile = new BufferedReader(new FileReader("input.txt"));
  19.         } catch(FileNotFoundException e) {
  20.             e.printStackTrace();
  21.         }
  22.        
  23.         Boolean bFound = false;
  24.         String sLine = null;
  25.        
  26.         try {
  27.             while((sLine = strFile.readLine()) != null) {
  28.                 String[] data = sLine.split(":");
  29.                 if(data[0].equals(Login)) {
  30.                     if(data[1].equals(hashPass)) {
  31.                         return true;
  32.                     }
  33.                 }
  34.             }
  35.         } catch(IOException e) {
  36.             e.printStackTrace();
  37.         }
  38.        
  39.         return false;
  40.        
  41.     }
  42.  
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement