What is the best way store leaked website credentials? I've come up with two that would get the job done for the most part, but I am trying to find the fastest and most efficient solution.
Take for example this site, which has a pretty basic search from the look of it, a more basic example would be the site haveibeenpwned. Doing a small scale test, so really I have two questions, first, would this be a good fit for a NoSQL style database? Or should I stick with a RDBMS? The second question is which structure would be able to return the results the fastest (and most completely)?
I could do it with something like this, but it would have lots of redundant information:
{ "uiid": "18c13cb5-bb91-41c6-8267-fd35e868d4c0",
"username": "foouser",
"email": "[email protected]",
"ip": "127.0.0.1",
"fullname": "Koolaid Man",
"phonenumber": "+1800123456",
"creds": [{
"hash": "1ed6c8f1465d39e64055e18762fca52850244c9aed2158d6e63406693e775b4a",
"algo": "sha256",
"salt": "andpepper",
"plaintext": "iesh0oow3ieg4thoweonga5aengeaGee3xahbohCuu6oog7oorei2jooPi1hooR6Shi9aoji7wu8ahreeG4see7Thothoo2ev7ch",
"dateadded": "2012-04-23T18:25:43.511Z"
},
{
"hash": "1ed6c8f1465d39e64055e18762fca52850244c9aed2158d6e63406693e775b4a",
"algo": "sha256",
"dateadded": "2012-04-23T18:25:43.511Z"
}
]
}
Using a RDMS, I could so something like this:
CREATE TABLE `identities` (
`uiid` UUID NOT NULL UNIQUE,
`email` INTEGER,
`username` INTEGER,
`fullname` INTEGER,
`ip` INTEGER,
-- ...
);
CREATE TABLE `hashed_plain` (
`uhid` UUID NOT NULL UNIQUE,
`type` INTEGER,
`hash` TEXT NOT NULL UNIQUE,
`salt` INTEGER,
`plain_text` INTEGER NOT NULL,
-- ...
);
CREATE TABLE `hash_instance` (
`id` UUID NOT NULL PRIMARY KEY UNIQUE,
`uhid` TEXT,
`uiid` TEXT,
-- ...
);
-- ...
I know that both of these are not very good implementations, hopefully someone more knowledgeable than myself can point me in the right direction.
- There Are Many "People" (by this I mean the information that identifies the user : username, email, ip ,name, etc.)
- There are many "Keys" (by this I mean the information that validates the person: password, hash, salt, etc.)
- Each Person can have many keys
- Each Key can have many People
I want to be able to search by any field (with the exception of the UUID's) and return everything else associated with that piece of information. What's the best way to do that?