Skip to content

Commit

Permalink
First Run
Browse files Browse the repository at this point in the history
  • Loading branch information
gdiggs committed Dec 11, 2010
0 parents commit 95a448c
Show file tree
Hide file tree
Showing 243 changed files with 161 additions and 0 deletions.
72 changes: 72 additions & 0 deletions Database.java
@@ -0,0 +1,72 @@

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;

public abstract class Database{

// add the username and password pair to the database
public static void addUsernameAndPasswordToDatabase(String username, String password) throws Exception{
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:pass_hash.db");

PreparedStatement statement = conn.prepareStatement("insert into passwords values (?, ?);");
statement.setString(1, username);
statement.setString(2, password);
statement.addBatch();

conn.setAutoCommit(false);
statement.executeBatch();
conn.setAutoCommit(true);

conn.close();
}

// create the database and tables if they don't already exist
public static void createDatabase() throws Exception{
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:pass_hash.db");
Statement stat = conn.createStatement();
stat.executeUpdate("create table if not exists passwords (username, password);");
conn.close();
}

public static String[][] getAllUsernameAndPasswordPairs() throws Exception{
int numRows = Database.numRowsInDB();
String result[][] = new String[numRows][2];
int index = 0;

Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:pass_hash.db");
Statement stat = conn.createStatement();

ResultSet rs = stat.executeQuery("select * from passwords;");

while (rs.next() && index<numRows){
result[index][0] = rs.getString("username");
result[index][1] = rs.getString("password");
index++;
}

rs.close();
conn.close();

return result;
}

public static int numRowsInDB() throws Exception{
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:pass_hash.db");
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery("select count(*) from passwords;");

int result = rs.getInt(1);

rs.close();
conn.close();

return result;
}
}
54 changes: 54 additions & 0 deletions DatabaseTester.java
@@ -0,0 +1,54 @@
/* This class simply uses the other classes to take in the username/password
* and show how everything works.
*/

import java.util.Scanner;

public class DatabaseTester{
public static void main(String[] args) throws Exception{
Scanner keyboard = new Scanner(System.in);
System.out.println("DatabaseTester - Let's encrypt and store some words");

System.out.print("Enter your username: ");
String username = keyboard.nextLine();

System.out.print("Enter your password: ");
String password = keyboard.nextLine();

System.out.println("Your username: " + username + "\nYour password: " + password);

// the Password class automatically encrypts the password when you instantiate it
// the constructor takes a string
Password passwd = new Password(password);

// Password's toString method returns the encrypted password
System.out.println("Your encrypted password: " + passwd);

// This is how you decrypt the password stored in the object
System.out.println("Your decrypted password: " + passwd.getDecryptedPassword());

// Password also has a static method to decrypt a formerly encrypyted/stored string
System.out.println("Your decrypted password with Password's static method: " + Password.decryptPassword(passwd.toString()));

// when we first run the program, we'll need to create the database
// createDatabase() only creates it if it doesn't already exist
// Database is abstract, so don't try to instantiate it
Database.createDatabase();

// to add a username and password to the database, just use this method
Database.addUsernameAndPasswordToDatabase(username, passwd.toString());

// this method will return all the rows of the database in a 2-dimensional array
String passwords[][] = Database.getAllUsernameAndPasswordPairs();

// this just prints the pairs
System.out.println("Here's all the pairs in the database!!");
for(int i=0; i<passwords.length; i++){
for(int j=0; j<passwords[i].length; j++){
System.out.print(passwords[i][j] + " ");
}
System.out.print("\n");
}

}
}
35 changes: 35 additions & 0 deletions Password.java
@@ -0,0 +1,35 @@
/* This class encrypts a password upon object creation and
* can decrypt it as well. It also decrypts a string.
*/

import org.jasypt.util.text.*;

public class Password{
private String password;
private static final String ENCRYPTOR_PASSWORD = "passhash and kittens 4ever";
private BasicTextEncryptor encryptor = new BasicTextEncryptor();

public Password(String newPassword){
encryptor.setPassword(ENCRYPTOR_PASSWORD);
String encryptedPassword = encryptor.encrypt(newPassword);
password = encryptedPassword;
}

public String getDecryptedPassword(){
return (String) encryptor.decrypt(this.password);
}

public String getEncryptedPassword(){
return (String) password;
}

public String toString(){
return (String) this.getEncryptedPassword();
}

public static String decryptPassword(String encryptedPassword){
BasicTextEncryptor encryptor2 = new BasicTextEncryptor();
encryptor2.setPassword(ENCRYPTOR_PASSWORD);
return (String) encryptor2.decrypt(encryptedPassword);
}
}
Binary file added icu4j-3.4.4.jar
Binary file not shown.
Binary file added jasypt-1.7.jar
Binary file not shown.
Binary file added org/ibex/nestedvm/ClassFileCompiler.class
Binary file not shown.
Binary file added org/ibex/nestedvm/Compiler$Exn.class
Binary file not shown.
Binary file added org/ibex/nestedvm/Compiler$Option.class
Binary file not shown.
Binary file added org/ibex/nestedvm/Compiler.class
Binary file not shown.
Binary file not shown.
Binary file added org/ibex/nestedvm/Interpreter.class
Binary file not shown.
Binary file added org/ibex/nestedvm/JavaSourceCompiler.class
Binary file not shown.
Binary file added org/ibex/nestedvm/Registers.class
Binary file not shown.
Binary file added org/ibex/nestedvm/Runtime$1.class
Binary file not shown.
Binary file added org/ibex/nestedvm/Runtime$CPUState.class
Binary file not shown.
Binary file added org/ibex/nestedvm/Runtime$CallException.class
Binary file not shown.
Binary file added org/ibex/nestedvm/Runtime$CallJavaCB.class
Binary file not shown.
Binary file added org/ibex/nestedvm/Runtime$ErrnoException.class
Binary file not shown.
Binary file added org/ibex/nestedvm/Runtime$ExecutionException.class
Binary file not shown.
Binary file added org/ibex/nestedvm/Runtime$FD.class
Binary file not shown.
Binary file added org/ibex/nestedvm/Runtime$FStat.class
Binary file not shown.
Binary file added org/ibex/nestedvm/Runtime$FaultException.class
Binary file not shown.
Binary file added org/ibex/nestedvm/Runtime$HostFStat.class
Binary file not shown.
Binary file not shown.
Binary file added org/ibex/nestedvm/Runtime$ReadFaultException.class
Binary file not shown.
Binary file added org/ibex/nestedvm/Runtime$SecurityManager.class
Binary file not shown.
Binary file added org/ibex/nestedvm/Runtime$SeekableFD.class
Binary file not shown.
Binary file added org/ibex/nestedvm/Runtime$SocketFStat.class
Binary file not shown.
Binary file added org/ibex/nestedvm/Runtime$TerminalFD$1.class
Binary file not shown.
Binary file added org/ibex/nestedvm/Runtime$TerminalFD.class
Binary file not shown.
Binary file not shown.
Binary file added org/ibex/nestedvm/Runtime$WriteFaultException.class
Binary file not shown.
Binary file added org/ibex/nestedvm/Runtime.class
Binary file not shown.
Binary file added org/ibex/nestedvm/RuntimeCompiler$1.class
Binary file not shown.
Binary file not shown.
Binary file added org/ibex/nestedvm/RuntimeCompiler.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$1.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$CygdriveFS.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$DevFS$1$1.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$DevFS$1.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$DevFS$2$1.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$DevFS$2.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$DevFS$3.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$DevFS$4.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$DevFS$5.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$DevFS$6.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$DevFS$DevDirFD.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$DevFS$DevFStat.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$DevFS.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$DirFD$1.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$DirFD.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$FS.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$ForkedProcess.class
Binary file not shown.
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$GlobalState$MP.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$GlobalState.class
Binary file not shown.
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$HostFS.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$Pipe$Reader.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$Pipe$Writer.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$Pipe.class
Binary file not shown.
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$ResourceFS$1.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$ResourceFS$2.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$ResourceFS.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime$SocketFD.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UnixRuntime.class
Binary file not shown.
Binary file added org/ibex/nestedvm/UsermodeConstants.class
Binary file not shown.
Binary file added org/ibex/nestedvm/crt0.o
Binary file not shown.
Binary file added org/ibex/nestedvm/support.o
Binary file not shown.
Binary file added org/ibex/nestedvm/support_aux.o
Binary file not shown.
Binary file added org/ibex/nestedvm/util/ELF$ELFException.class
Binary file not shown.
Binary file added org/ibex/nestedvm/util/ELF$ELFHeader.class
Binary file not shown.
Binary file added org/ibex/nestedvm/util/ELF$ELFIdent.class
Binary file not shown.
Binary file added org/ibex/nestedvm/util/ELF$PHeader.class
Binary file not shown.
Binary file added org/ibex/nestedvm/util/ELF$SHeader.class
Binary file not shown.
Binary file not shown.
Binary file added org/ibex/nestedvm/util/ELF$Symbol.class
Binary file not shown.
Binary file added org/ibex/nestedvm/util/ELF$Symtab.class
Binary file not shown.
Binary file added org/ibex/nestedvm/util/ELF.class
Binary file not shown.
Binary file added org/ibex/nestedvm/util/InodeCache.class
Binary file not shown.
Binary file added org/ibex/nestedvm/util/Platform$Jdk11.class
Binary file not shown.
Binary file added org/ibex/nestedvm/util/Platform$Jdk12.class
Binary file not shown.
Binary file added org/ibex/nestedvm/util/Platform$Jdk13.class
Binary file not shown.
Binary file added org/ibex/nestedvm/util/Platform$Jdk14.class
Binary file not shown.
Binary file not shown.
Binary file added org/ibex/nestedvm/util/Platform.class
Binary file not shown.
Binary file added org/ibex/nestedvm/util/Seekable$ByteArray.class
Binary file not shown.
Binary file added org/ibex/nestedvm/util/Seekable$File.class
Binary file not shown.
Binary file added org/ibex/nestedvm/util/Seekable$InputStream.class
Binary file not shown.
Binary file added org/ibex/nestedvm/util/Seekable$Lock.class
Binary file not shown.
Binary file added org/ibex/nestedvm/util/Seekable.class
Binary file not shown.
Binary file added org/ibex/nestedvm/util/Sort$1.class
Binary file not shown.
Binary file added org/ibex/nestedvm/util/Sort$Comparable.class
Binary file not shown.
Binary file added org/ibex/nestedvm/util/Sort$CompareFunc.class
Binary file not shown.
Binary file added org/ibex/nestedvm/util/Sort.class
Binary file not shown.
Binary file added org/jasypt/commons/CommonUtils.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added org/jasypt/digest/ByteDigester.class
Binary file not shown.
Binary file added org/jasypt/digest/PooledByteDigester.class
Binary file not shown.
Binary file added org/jasypt/digest/PooledStringDigester.class
Binary file not shown.
Binary file added org/jasypt/digest/StandardByteDigester.class
Binary file not shown.
Binary file added org/jasypt/digest/StandardStringDigester.class
Binary file not shown.
Binary file added org/jasypt/digest/StringDigester.class
Binary file not shown.
Binary file added org/jasypt/digest/config/DigesterConfig.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added org/jasypt/digest/config/StringDigesterConfig.class
Binary file not shown.
Binary file added org/jasypt/encryption/BigDecimalEncryptor.class
Binary file not shown.
Binary file added org/jasypt/encryption/BigIntegerEncryptor.class
Binary file not shown.
Binary file added org/jasypt/encryption/ByteEncryptor.class
Binary file not shown.
Binary file added org/jasypt/encryption/StringEncryptor.class
Binary file not shown.
Binary file added org/jasypt/encryption/pbe/NumberUtils.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added org/jasypt/encryption/pbe/PBEByteEncryptor.class
Binary file not shown.
Binary file added org/jasypt/encryption/pbe/PBEStringEncryptor.class
Binary file not shown.
Binary file added org/jasypt/encryption/pbe/PasswordBased.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added org/jasypt/encryption/pbe/config/PBEConfig.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added org/jasypt/hibernate/type/ParameterNaming.class
Binary file not shown.
Binary file added org/jasypt/intf/cli/AlgorithmRegistryCLI.class
Binary file not shown.
Binary file added org/jasypt/intf/cli/ArgumentNaming.class
Binary file not shown.
Binary file added org/jasypt/intf/cli/CLIUtils.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added org/jasypt/intf/cli/JasyptStringDigestCLI.class
Binary file not shown.
Binary file not shown.
Binary file added org/jasypt/normalization/Normalizer.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added org/jasypt/registry/AlgorithmRegistry.class
Binary file not shown.
Binary file added org/jasypt/salt/FixedByteArraySaltGenerator.class
Binary file not shown.
Binary file added org/jasypt/salt/FixedStringSaltGenerator.class
Binary file not shown.
Binary file added org/jasypt/salt/RandomSaltGenerator.class
Binary file not shown.
Binary file added org/jasypt/salt/SaltGenerator.class
Binary file not shown.
Binary file added org/jasypt/salt/ZeroSaltGenerator.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added org/jasypt/spring/security/PasswordEncoder.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added org/jasypt/spring/security3/PasswordEncoder.class
Binary file not shown.
Binary file not shown.
Binary file added org/jasypt/util/binary/BasicBinaryEncryptor.class
Binary file not shown.
Binary file added org/jasypt/util/binary/BinaryEncryptor.class
Binary file not shown.
Binary file added org/jasypt/util/binary/StrongBinaryEncryptor.class
Binary file not shown.
Binary file added org/jasypt/util/digest/Digester.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added org/jasypt/util/numeric/DecimalNumberEncryptor.class
Binary file not shown.
Binary file added org/jasypt/util/numeric/IntegerNumberEncryptor.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added org/jasypt/util/password/PasswordEncryptor.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added org/jasypt/util/text/BasicTextEncryptor.class
Binary file not shown.
Binary file added org/jasypt/util/text/StrongTextEncryptor.class
Binary file not shown.
Binary file added org/jasypt/util/text/TextEncryptor.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added org/jasypt/web/pbeconfig/WebPBEInitializer.class
Binary file not shown.
Binary file added org/jasypt/wicket/JasyptCrypt.class
Binary file not shown.
Binary file added org/jasypt/wicket/JasyptCryptFactory.class
Binary file not shown.
Binary file added org/sqlite/Codes.class
Binary file not shown.
Binary file added org/sqlite/Conn.class
Binary file not shown.
Binary file added org/sqlite/DB.class
Binary file not shown.
Binary file added org/sqlite/Function$Aggregate.class
Binary file not shown.
Binary file added org/sqlite/Function.class
Binary file not shown.
Binary file added org/sqlite/JDBC.class
Binary file not shown.
Binary file added org/sqlite/MetaData.class
Binary file not shown.
Binary file added org/sqlite/NativeDB.class
Binary file not shown.
Binary file added org/sqlite/NestedDB$CausedSQLException.class
Binary file not shown.
Binary file added org/sqlite/NestedDB.class
Binary file not shown.
Binary file added org/sqlite/PrepStmt.class
Binary file not shown.
Binary file added org/sqlite/RS.class
Binary file not shown.
Binary file added org/sqlite/SQLite.class
Binary file not shown.
Binary file added org/sqlite/Stmt.class
Binary file not shown.
Binary file added org/sqlite/Unused.class
Binary file not shown.
Binary file added sqlitejdbc-v054.jar
Binary file not shown.

0 comments on commit 95a448c

Please sign in to comment.