A very, very, very light-weight utility for Java applications allowing you to store all kind of serializable object in one or more files under a certain key.
Send some kind of warning message when a password is longer than 16 chars, because if it is longer than 16 characters, only the first 16 characters will be used for the encryption.
If the password in DB.get("ID", "PASSWORD"); is wrong, it throws an exception:
javax.crypto.BadPaddingException: Given final block not properly padded
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:989)
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:845)
at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:446)
at javax.crypto.Cipher.doFinal(Cipher.java:2165)
at com.blogspot.debukkitsblog.Crypt.Crypter.decrypt(Crypter.java:54)
at com.blogspot.debukkitsblog.Crypt.Crypter.decrypt(Crypter.java:33)
at com.blogspot.debukkitsblog.Util.FileStorage.get(FileStorage.java:117)
at dbtest.main(Main.java:37)
Exception in thread "main" java.lang.NullPointerException
at dbtest.main(Main.java:37)
instead, it should either print a message with "Wrong password" or something like this, or it should print out the "garbage" of the decryption result, but not an error. :D
Edit:
3: Please add the ability to specify the password key too in getAll() and printAll() :D
In der Datei Crypter.java zeile 121 wird in der while schleife anstatt resultKey key verwendet.
Dadurch ensteht eine unendlichschleife die am ende in einem Java Heap Space error endet.
/*** All stored objects in an ArrayList of Objects* @return all stored objects in an ArrayList of Objects*/publicArrayList<Object> getAllObjects(){
ArrayList<Object> result = newArrayList<Object>();
for(Objectc: storageMap.values()){
result.add(c);
}
returnresult;
}
/*** All stored objects and keys in an HashMap of String and Objects* @return all stored objects and keys in an HashMap of String and Objects*/publicHashMap<String, Object> getAll(){
returnstorageMap;
}
Improvement suggestion: Add the ability to store data in an encrypted format, for example with AES encryption and with a key that can be specified when an object is stored in the database.