Documentation ¶
Overview ¶
Package hashdb provides a database for hex-based hashes.
This package needs kuroneko's sqlite3 library (https://github.com/kuroneko/gosqlite3).
HashMix Sample
// Create a new hash-mix in memory. mix, err := OpenMix(":memory:", 10) if err != nil { return err } // Add new entry err = mix.Put("MT1992") if err != nil { return err } // Get entry passwordMap, err := mix.GetMD5("5f87e0f786e60b554ec522ce85ddc930") // or mix.GetMD5("5f87e0f") if err != nil { return err }
HashDB Sample
// Create a new database in memory. db, err := OpenDatabase(":memory:", md5.New(), 10) if err != nil { return err } // Add new entry err = db.Put("MT1992") if err != nil { return err } // Get entry password, err := db.GetExact("5f87e0f786e60b554ec522ce85ddc930") if err != nil { return err }
Index ¶
Constants ¶
const HexAlphabet = "0123456789abcdef"
Variables ¶
var ( ErrCreatingDatabase = errors.New("Error while creating Database.") ErrCreatingTable = errors.New("Error while creating Table.") ErrCreatingIndex = errors.New("Error while creating Index.") ErrInitExactHandlerFailed = errors.New("Exact-handler initialization failed.") ErrInitLikeHandlerFailed = errors.New("Like-handler initialization failed.") ErrInitPutHandlerFailed = errors.New("Put-handler initialization failed.") ErrHashTooShort = errors.New("The length of the hash is too short.") ErrDatastoreNotFound = errors.New("The requested datastore was not found.") ErrDirectoryNotFound = errors.New("The directory doesn't exist.") ErrPasswordMissing = errors.New("Password parameter is empty.") ErrWrongHashFormat = errors.New("Hash-format is wrong.") )
Functions ¶
This section is empty.
Types ¶
type Datastore ¶
type Datastore struct {
// contains filtered or unexported fields
}
func OpenDatastore ¶
OpenDatastore creates a new Datastore and binds it to the backend database.
func (*Datastore) GetLike ¶
func (ds *Datastore) GetLike(request *GetRequest)
GetLike returns all matching passwords for the supplied hash.
hash LIKE ?
type GetRequest ¶
type GetRequest struct {
// contains filtered or unexported fields
}
type GetResponse ¶
type GetResponse struct {
// contains filtered or unexported fields
}
type HashDB ¶
type HashDB struct {
// contains filtered or unexported fields
}
func OpenDatabase ¶
OpenDatabase creates or opens a new HashDB instance. directory accepts a valid directory or ":memory:" if you want the database only in RAM.
func (*HashDB) GetExact ¶
GetExact searches for the hash in the database. The hash parameter has to be lower-case.
func (*HashDB) GetLike ¶
GetLike searches in the database for a hash that contains the supplied hash-part.
func (*HashDB) Put ¶
func (db *HashDB) Put(password string, resultChan chan *PutResponse)
Put stores a new hash in the database. The hash is stored as lower-case.
type HashMix ¶
type HashMix struct {
// contains filtered or unexported fields
}
func (*HashMix) Put ¶
func (hm *HashMix) Put(password string, responseChan chan *PutResponse)
Put stores the new password in the MD5 and SHA1 database. The responseChan gets two messages - one for each HashDB.
type LookupTable ¶
type PutRequest ¶
type PutRequest struct {
// contains filtered or unexported fields
}
type PutResponse ¶
type PutResponse struct {
// contains filtered or unexported fields
}
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
This http-"server" understands three different requests: - /md5?q=AAAAAAA -> searches the MD5 hash in the database - /sha1?q=BBBBBB -> searches the SHA1 hash in the database - /new?p=newPassword -> adds the password to the database Before the server is started the first time the "db" folder has to be created: - `mkdir db db/md5 db/sha1`
|
This http-"server" understands three different requests: - /md5?q=AAAAAAA -> searches the MD5 hash in the database - /sha1?q=BBBBBB -> searches the SHA1 hash in the database - /new?p=newPassword -> adds the password to the database Before the server is started the first time the "db" folder has to be created: - `mkdir db db/md5 db/sha1` |