eggbe/hash-store

File-based library for easy manage a list of hashes


Keywords
security, storage, lightweight, hash, file-based, MD5, hashes, Lists
License
MIT

Documentation

Introduction

This is the powerful library provides an easiest way to create and manage your own list of hashes.

Features

The library is fully file-based so you don't need to use any databases.

Requirements

Install

Here's a pretty simple way to start using Eggbe/HashStore:

Step 1: Use Composer to add Eggbe/HashStore in your project:

composer require eggbe/hash-store

Step 2: Create and configure an instance of the object anywhere in your code:

$HashStore = new \Eggbe\HashStore\HashStore([
    'path' => 'path-to-storage-directory',
    'sort' => HashStore::BY_DATE | HashStore::BY_DESC,
    'filter' => '^.{0,32}$',
]);

The path option define the directory to store all generated files. Please, pay attention what you will get an exception if this directory doesn't exists. Also the sort option specifies the type of sorting and the filter option set a regular expression for keywords filtering. If any keyword won't match this expression the special exception will be thrown.

Sorting

All hashes stored with a timestamp to have an ability for extended sorting features. Currently it possible to sort hashes by:

  • Keywords in direct order ('sort' => HashStore::BY_WORD)
  • Keywords in converse order ('sort' => HashStore::BY_WORD | HashStore::BY_DESC)
  • Dates by descending ('sort' => HashStore::BY_DATE)
  • Dates by ascending ('sort' => HashStore::BY_DATE | HashStore::BY_DESC)

Usage

You have to use the following method to create and add new hash into storage:

$HashStore->create('keyword');

Of course you always can view all existing hashes via the following code:

foreach($HashStore->all() as $keyword => $content){
    echo $keyword . ' ' . $content;
}  

The following method help you to find any hash by a keyword:

$hash = $HashStore->find('keyword');

If you need to get a keyword by a hash so it also possible:

$keyword = $HashStore->search('a2f51b04c9a31cd2defc4d3550eecb71');

And of course you can remove any hash if you really wish:

$HashStore->remove('keyword');

Unfortunately currently this library support only md5 hashes usage but we have plans to extend of the functionality. We will keep you in touch!

Authors

Made with love at Eggbe.

Feedback

We always welcome your feedback at github@eggbe.com.

License

This package is released under the MIT license.