ID hashes are computed by first ciphering the object's ID using a 4-byte Speck Cipher then converted to a base62 left-padded 6 character string.
make # build Docker image
docker-compose up -d # run docker-compose file
./shell # bash shell of running container
username: root
password: asdf1234
saveurl.sh
, geturl.sh
, and getredirect.sh
use jq
for parsing JSON responses. These can be run from inside the running Docker container.
./shell # Connect to running docker container
./saveurl.sh https://www.google.ca # Create shortened url
> http://0.0.0.0:8000/d5wm82
./geturl.sh https://www.google.ca # Query shortened url
> http://0.0.0.0:8000/d5wm82
./getredirect.sh d5wm82 # Query redirect url
> https://www.google.ca
./saveurl.sh "https://arstechnica.com/tech-policy/2019/09/nyc-sues-t-mobile-to-stop-rampant-and-abusive-sales-tactics/"
> http://0.0.0.0:8000/c2DJVC
query {
allUrls {
id
url
}
}
query {
getHashId: url(url: "https://www.google.com") {
hashId
}
getUrl: url(hashId: "d5wm82") {
url
}
}
query {
url(id: 1) {
hashId
}
anotherUrl: url(url: "https://www.google.com") {
url
hashId
}
}
mutation {
createUrl(url: "https://www.theverge.com") {
ok
url {
id
url
hashId
}
}
}
docker-compose -f docker-compose-dev.yml up -d # Start container with src directory mounted to /root/src
./shell # Get bash shell in container
./bootstrap.sh # Create database
./manage.py test # Run tests
./manage.py shell_plus # Get Django shell