go-sdk/examples/crypto
syedsadath-17 d655a2c770
Examples: Added Crypto (#492)
* Examples: Added Crypto

Signed-off-by: sadath-12 <sadathsadu2002@gmail.com>

* docs: update

Signed-off-by: sadath-12 <sadathsadu2002@gmail.com>

---------

Signed-off-by: sadath-12 <sadathsadu2002@gmail.com>
2024-01-19 08:54:36 -08:00
..
components Examples: Added Crypto (#492) 2024-01-19 08:54:36 -08:00
README.md Examples: Added Crypto (#492) 2024-01-19 08:54:36 -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

Step

Prepare

  • Dapr installed

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

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

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