Decrypting a file in Java and exporting it to a file without going into infinite loops?

A few hints towards your code: insert comments that describe why you do things (to help you maintain / understand it later) define private final constants for the magic strings like "AES" and "data. Txt" that are copied all over now (less chance of typoes and easier to change if need be) use base types hiding implementation details where possible, i.e. List usersList instead of trying to keep the usersList and passwordsList in synch, you could also create a Map for storing passwords for usernames.

Some remarks on your code: Don't store plaintext passwords... it's just bad. Why are you doing this: usersList. Add(usersList.size(), user); passwordList.

Add(usersList.size()-1, password); Honestly, I don't get it. Why don't you just .add() to the according list? Why do you .clear() the lists when you have checked before that they are already empty?

Why won't you let two users have the same password? For your exporting problem (I think it won't be too hard to adapt it): KeyGenerator kg = KeyGenerator. GetInstance("DES"); kg.

Init(new SecureRandom()); SecretKey key = kg.generateKey(); SecretKeyFactory skf = SecretKeyFactory. GetInstance("DES"); Class spec = Class. ForName("javax.crypto.spec.

DESKeySpec"); DESKeySpec ks = (DESKeySpec) skf. GetKeySpec(key, spec); ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("keyfile")); oos. WriteObject(ks.getKey()); Cipher c = Cipher.

GetInstance("DES/CFB8/NoPadding"); c. Init(Cipher. ENCRYPT_MODE, key); CipherOutputStream cos = new CipherOutputStream(new FileOutputStream("ciphertext"), c); PrintWriter pw = new PrintWriter(new OutputStreamWriter(cos)); pw.

Println("Stand and unfold yourself"); pw.close(); oos. WriteObject(c.getIV()); oos.close(); From here: http://www.java2s.com/Tutorial/Java/0490%5F%5FSecurity/UsingCipherOutputStream.htm.

3, he checked one of them is empty and clears both – rsp Dec 26 '09 at 9:22 yes I noticed that. But isn't that a strange thing to do? I mean if you have more passwords than users or vice versa is it then really clever to delete everything?

And in the code as posted above, if I'm not mistaken, is no possibility to ever run into such a situation – Chris Dec 26 '09 at 9:26.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions