Be a Supporter!

Java Password Manager

  • 305 Views
  • 7 Replies
New Topic Respond to this Topic
Boltrig
Boltrig
  • Member since: Mar. 17, 2006
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Java Password Manager 2007-03-28 12:47:53 Reply

Hey all. Ive got an asignment to make a java password manager. Doesnt have to be uber complex or anything and it wont be used outside of a theory lab (so no encryption required). The only stipulations are:

1)have a binary search tree, or more advanced data structures, to store the user names and passwords. A list is not acceptable in this asignment
2) validate usernames and passwords
3) give meaningul interaction with the user

Anything else is just gravy.

I cant get my head around the node having 2 data types for comparison. Any ideas on how to compare firstly JUST the username to see if it exists and then compare the password if it does indeed exist.

Thanks in advance all.

Jon-86
Jon-86
  • Member since: Jan. 30, 2007
  • Offline.
Forum Stats
Member
Level 14
Blank Slate
Response to Java Password Manager 2007-03-28 13:23:05 Reply

If its in Java and your using strings instead of a char array to store the usernames then a simple.

if(stored_name == name_your_looking_for)
{
//Check the password / phrase is valid
}
else
{
System.out.print("Name could not be found"};
}

That should work and you could put that inside a loop to loop through all the names you have.
Then all you need to worry about is what way you want to traverse the tree.
And that depends on how its defined.


PHP Main :: C++ Main :: Java Main :: Vorsprung durch Technik
irc.freenode.net #ngprogramming

BBS Signature
Jon-86
Jon-86
  • Member since: Jan. 30, 2007
  • Offline.
Forum Stats
Member
Level 14
Blank Slate
Response to Java Password Manager 2007-03-28 13:26:53 Reply

More ways to compare strings in Java.

String s = "something", t = "maybe something else";

if (s == t) // Legal, but usually wrongly.
if (s.equals(t)) // ok
if (s.compareTo(t) > 0) // ok


PHP Main :: C++ Main :: Java Main :: Vorsprung durch Technik
irc.freenode.net #ngprogramming

BBS Signature
Boltrig
Boltrig
  • Member since: Mar. 17, 2006
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to Java Password Manager 2007-03-28 13:28:10 Reply

At 3/28/07 01:23 PM, Jon-86 wrote:
That should work and you could put that inside a loop to loop through all the names you have.
Then all you need to worry about is what way you want to traverse the tree.
And that depends on how its defined.

Thanks man. I shall investigate traversing the trees =]

Jon-86
Jon-86
  • Member since: Jan. 30, 2007
  • Offline.
Forum Stats
Member
Level 14
Blank Slate
Response to Java Password Manager 2007-03-28 13:39:08 Reply

No problem.

If you need any more help then post away.


PHP Main :: C++ Main :: Java Main :: Vorsprung durch Technik
irc.freenode.net #ngprogramming

BBS Signature
RageOfOrder
RageOfOrder
  • Member since: Aug. 30, 2002
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to Java Password Manager 2007-03-28 13:45:18 Reply

searching a tree isn't hard.

From your Tree class, check to make sure the tree isn't empty, and then call search on the root node.

At the node level you have a recursive function.
Create a variable to hold your return object, set it to null.
Base case:
This node is the one containing your data, and you return it.
Else:
This is not the right node, so call search on the left child and store it in your variable. If it comes back as null, call search on the right child, and store that in the return variable.

Return your variable.

Done.
I'll explain further if you like.....

RageOfOrder
RageOfOrder
  • Member since: Aug. 30, 2002
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to Java Password Manager 2007-03-28 13:51:30 Reply

As an afterthought, a hash table might be a good way to go for this, because if you have a binary tree, you still need a way to sort the data.
My suggestion would be something like convert each character in the string to an integer, and subtract the position it's in from the number.
Of course thats a hash right there, so you might as well use a hash table.

Makes things a lot faster to access, since all you have to do is ask a user for their name / pass, hash the name and see if the passwords match.
O(1) time, ideally.

You'd still have to account for overlapping hash values, but it shouldn't be a problem

henke37
henke37
  • Member since: Sep. 10, 2004
  • Offline.
Forum Stats
Member
Level 30
Blank Slate
Response to Java Password Manager 2007-03-29 03:15:29 Reply

My suggestion: use a map. Possibly a hashed map.


Each time someone abuses hittest, God kills a kitten. Please, learn real collision testing.