Skip to content

This API provides features on generation of MD5 hashes based on provided strings and following certain rules.

Notifications You must be signed in to change notification settings

edumarques/hashing-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Hashing API

This API provides a route that generates an MD5 hash based on a provided string and following certain rules. It also provides a route to get the stored results (done by the command described below).

This project also provides a command (via CLI) which makes requests to the hashing route and saves its results in the database.

Building and running the project

This project is built on docker containers. So to build it, either the direct docker-compose command can be executed or some make commands.

docker-compose up -d --build
make build-d
make up-d

There are more helpful commands as well using make:

help            Shows this help
build           Build all docker images from docker-compose.yml
build-d         Detached mode: Build all docker images from docker-compose.yml
up              Lift containers already built
down-up         Lift containers already built (down first)
up-d            Detached mode: Run containers in the background, print new container names
down-up-d       Detached mode: Run containers in the background, print new container names (down first)
ps              Check containers statuses
recreate        Recreate containers even if their configuration and image haven't changed
down-recreate   Recreate containers even if their configuration and image haven't changed (down first)
down            Stop containers and removes containers, networks, volumes, and images created by up.
remove-orphans  Remove containers for services not defined in the docker-compose file
migrate         Run application migrations
migrate-diff    Run migrations diff
insights        Run PHP insights
insights-fix    Run PHP insights fix
test            Run tests
test-cov        Run tests and generate coverage report

Running the features

Route to generate an MD5 hash

This route receives a string as POST parameter and is designed to calculate a correspondent md5 hash based on the concatenation of the provided string and a random generated key of 8 digits. Also, for the hash to be valid, it needs to be prefixed with "0000". The route returns the generated hash, its used key and the number of attempts to find the correspondent hash.

POST /hash

{
  "stringToHash": "<some_string>"
}

Command to request to the MD5 hashing route

This command receives an argument that represents the string to be hashed and an option that corresponds to the amount of consecutive requests the script will make to that route. The provided string is only used in the first iteration, while the input string used from the second iteration onwards will be the generated hash from the previous iteration.

docker-compose exec php bin/console avato:test <string_to_be_hashed> --requests=<number_of_requests>

Route to query the stored hashing batches

This route returns the stored batches that were executed by the command above. The response is paginated and can also be filtered by "all batches with attempts less than a provided number".

GET /hashing-batches/{page}?attemptsLessThan=<number_of_attempts>

Project's used packages/libraries

  • Symfony Framework
  • Doctrine ORM
  • Knp Paginator bundle
  • PHPUnit
  • PHP Insights

About

This API provides features on generation of MD5 hashes based on provided strings and following certain rules.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published