go-sdk/examples/crypto
Mike Nguyen 0c60bbd3a4
fix: add crypto validation example and fix mechanical markdown (#544)
* fix: add crypto validation example and fix mechanical markdown

Signed-off-by: mikeee <hey@mike.ee>

* fix: update test assertion and remove cleanup step

Signed-off-by: mikeee <hey@mike.ee>

---------

Signed-off-by: mikeee <hey@mike.ee>
2024-05-06 15:35:18 +08:00
..
components Examples: Added Crypto (#492) 2024-01-19 08:54:36 -08:00
README.md fix: add crypto validation example and fix mechanical markdown (#544) 2024-05-06 15:35:18 +08:00
desert.jpg Examples: Added Crypto (#492) 2024-01-19 08:54:36 -08:00
main.go Examples: Added Crypto (#492) 2024-01-19 08:54:36 -08:00

README.md

Dapr Crypto Example with go-sdk

Steps

Prepare

  • Dapr installed

In order to run this sample, make sure that OpenSSL is available on your system.

Running

  1. This sample requires a private RSA key and a 256-bit symmetric (AES) key. We will generate them using OpenSSL:
mkdir -p keys
# Generate a private RSA key, 4096-bit keys
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:4096 -out keys/rsa-private-key.pem
# Generate a 256-bit key for AES
openssl rand -out keys/symmetric-key-256 32
  1. Run the Go service app with Dapr:
dapr run --app-id crypto --resources-path ./components/ -- go run .

Cleanup

ctrl + c to stop execution

dapr stop --app-id crypto
(lsof -i:8080 | grep crypto) | awk '{print $2}' | xargs  kill

Result

== APP == Encrypted the message, got 856 bytes
== APP == Decrypted the message, got 24 bytes
== APP == The secret is "passw0rd"
== APP == Wrote encrypted data to encrypted.out
== APP == Wrote decrypted data to decrypted.out.jpg