node src/app/server.js -p 3500 0 1000
curl http://localhost:3500/
Then we want to create a file, ideally with a unique value on whats past the hyphen.
At this point we'll want to create a random ID. At this point it creates a file with extension
*.md.enc
. However, it does not yet do the encryption yet.
curl "http://localhost:3500/v1/create/bob-${RANDOM%899999+100000}" \
-X POST \
-H 'Connection: keep-alive' \
-H 'Pragma: no-cache' \
-d 'defba315ababa315ababa315ababafed'
If the file starts as myfile.md
the server will automatically save it as myfile.md.enc
. So for now, the user must remember that they must
curl 'http://localhost:3500/v1/view/bob' \
-X POST \
-H 'Connection: keep-alive' \
-H "Content-Type: application/json" \
-H 'Pragma: no-cache' \
-d '{"jsonrpc":"2.0","method":"view","params":["name=draymond&password=deaba315ababa315adeaa315deabafed"],"id":26252}'
Then we want to protect Bob. Remember what that ID was. When you make this request, you'll need to pass that in the arguments
curl 'http://localhost:3000/v0/protect/bob-321321' \
-X POST \
-H 'Connection: keep-alive' \
-H 'Pragma: no-cache' \
-d 'name=draymond&password=deaba315ababa315adeaa315deabafed'
🔦 Next task. Send multiple arguments in a curl request
echo $((RANDOM%899999+100000))
Outputs a number such as 103879
. To put a command in a command, use either backticks or $()
.
From a web search
curl -d "param1=value1¶m2=value2" -X POST http://localhost:3000/data
-
In console
node src/app/server.js 0 100
and expect message that its running on port. You can also runnode src/app/server.js -p 3500 0 100
to customize port -
In a new console run
curl http://localhost:3000/
and expect to see an Info Message about the API -
Create: Then without file extension do
curl 'http://localhost:3000/v0/create/alice-32523' \
-X POST \
-H 'Connection: keep-alive' \
-H 'Pragma: no-cache' \
-H "Content-Type: application/x-www-form-urlencoded"
and you can check the store
directory to create that file
- Protect: Then verify with this
curl 'http://localhost:3500/v0/lock/' \
-X POST \
-H 'Connection: keep-alive' \
-H 'Pragma: no-cache' \
-d 'filename=logins.csv&extension=csv' \
-d 'password=12345678' -vvv
- View: Another option
curl 'http://localhost:3000/v0/view/alice-32523' \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"protect","params":[],"id":0}'
- Unlock: Unlock with the following
curl 'http://localhost:3500/v0/unlock/' \
-X PUT \
-H 'Connection: keep-alive' \
-H 'Pragma: no-cache' \
-d 'filename=logins&extension=csv' \
-d 'password=12345678' -vvv
curl 'http://localhost:3000/v0/unlock/alice-32526' \
-X PUT \
-H 'Connection: keep-alive' \
-H 'Pragma: no-cache' \
-d 'name=draymond&skill=archery&password=defba315ababa315ababa315ababafed'
- View: View file
curl 'http://localhost:3000/v0/view/alice-32523'
curl 'http://localhost:3000/v0/view/alice-32523' \
-X POST \
-H "Content-Type: application/json"
- Test: This is optional
Starting state is that /static/logins.csv.enc
is an encrypted file.
Our goal is to decrypt it.
It has signature app.put('/v0/unlock/:filename'
curl 'http://localhost:3000/v0/unlock/' \
-X PUT \
-H 'Connection: keep-alive' \
-H 'Pragma: no-cache' \
-d 'filename=logins&extension=csv' \
-d 'password=defba315ababa315ababa315ababafed'
Then test it with
curl 'http://localhost:3000/v0/view/' \
-X PUT \
-H 'Connection: keep-alive' \
-H 'Pragma: no-cache' \
-d '{"filename"="logins.csv"}'
Comment is that password above may not be most up to date
Documentation tend to say
curl -X PUT -d arg=val -d arg2=val2 localhost:8080
- Protect: Writing a new file
Status: This does not work yet
curl 'http://localhost:3500/v1/protect/' \
-X POST \
-H 'Connection: keep-alive' \
-H 'Pragma: no-cache' \
-d 'defba315ababa315ababa315ababafed' -vvv
- Unlock: Decryption version of above Experimental
curl 'http://localhost:3000/v1/unlock/myfilename' \
-X POST \
-H 'Connection: keep-alive' \
-H 'Pragma: no-cache' \
-d 'defba315ababa315ababa315ababafed'
- Create: Upgraded version of create, make this and then it will encrypt which needs to have the enc dec key be sent as part of jsonrpc request Experimental
curl 'http://localhost:3000/v1/create/bob-331331' \
-X POST \
-H 'Connection: keep-alive' \
-H 'Pragma: no-cache' \
-d 'defba315ababa315ababa315ababafed'
It may be wise to generate a random entry for key conflicts
- Experimental: Viewing new file
node test/readerstream.js '/d' init myetherfile.md 324234_266268
- Experimental: Test writing with promise based pattern
node test/writerstream.js '/d' init myetherfile.md 84935_484837
- Experimental: When interacting from local to cloud server
curl -X POST www.mmydomainname.com/v0/updates -L \
-H 'Pragma: no-cache'
cd src
node aes.js encrypt file.txt 12345678
node aes.js decrypt file.txt.enc 12345678
node aes.js encrypt file.md helloWorld
node aes.js decrypt file.md.enc helloWorld
Another variation could be
node src/test.js
cd test
node readerstream.js
/**
dcStore will start as
inner file: ./static/logins.csv.enc
arr1: [ '', '/static/logins', 'csv', 'enc' ]
arrPop: [ '', '/static/logins', 'csv' ]
arrUnshift: [ 'unenc', '', '/static/logins', 'csv' ]
err in write stream: [Error: ENOENT: no such file or directory, open 'unenc../static/logins.csv'] {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: 'unenc../static/logins.csv'
}
*/