https://github.com/edumarques/hashing-api
This API provides features on generation of MD5 hashes based on provided strings and following certain rules.
https://github.com/edumarques/hashing-api
Last synced: 5 days ago
JSON representation
This API provides features on generation of MD5 hashes based on provided strings and following certain rules.
- Host: GitHub
- URL: https://github.com/edumarques/hashing-api
- Owner: edumarques
- Created: 2021-11-14T15:32:06.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-16T11:55:57.000Z (over 4 years ago)
- Last Synced: 2025-06-10T13:48:49.127Z (about 1 year ago)
- Language: PHP
- Homepage:
- Size: 85 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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
docker-compose up -d --build
```
```make
make build-d
make up-d
```
There are more helpful commands as well using `make`:
```text
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```
```json
{
"stringToHash": ""
}
```
### 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
docker-compose exec php bin/console avato:test --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=```
## Project's used packages/libraries
- Symfony Framework
- Doctrine ORM
- Knp Paginator bundle
- PHPUnit
- PHP Insights