Created
September 2, 2013 18:58
-
-
Save hakusaro/6416141 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int generateValidPinCode(String seed) { | |
int pin = 0; | |
Random r = new Random(System.nanoTime() + seed.hashCode()); | |
int randombit = r.nextInt(9) * 1000 + r.nextInt(999); | |
ResultSet results = sqlDatabase.executeQuery("SELECT * FROM warnings WHERE pin=?", randombit); | |
try { | |
if (results.next()) { | |
pin = generateValidPinCode(Integer.toString(randombit)); | |
} else { | |
pin = randombit; | |
} | |
} catch (SQLException e) { | |
pin = randombit; | |
} | |
return pin; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment