mirror of https://github.com/dapr/rust-sdk.git
Added README.md
Signed-off-by: Zachary Edgell <zacharyedgell@gmail.com>
This commit is contained in:
parent
17671f0492
commit
a0b154dac4
|
@ -0,0 +1,40 @@
|
|||
# Crypto Example
|
||||
|
||||
This is a simple example that demonstrates Dapr's Cryptography capabilities.
|
||||
|
||||
> **Note:** Make sure to use latest version of proto bindings.
|
||||
|
||||
## Running
|
||||
|
||||
> Before you run the example make sure generate keys in examples/crypto/keys directory:
|
||||
> ```
|
||||
> 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
|
||||
> ```
|
||||
|
||||
To run this example:
|
||||
|
||||
1. Run the multi-app run template:
|
||||
|
||||
<!-- STEP
|
||||
name: Run Subscriber
|
||||
output_match_mode: substring
|
||||
match_order: none
|
||||
expected_stdout_lines:
|
||||
- '== APP - crypto-example == Successfully Decrypted String'
|
||||
- '== APP - crypto-example == Successfully Decrypted Image'
|
||||
background: true
|
||||
sleep: 30
|
||||
timeout_seconds: 90
|
||||
-->
|
||||
|
||||
```bash
|
||||
dapr run -f .
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
||||
2. Stop with `ctrl + c`
|
|
@ -8,4 +8,4 @@ spec:
|
|||
metadata:
|
||||
- name: path
|
||||
# Path is relative to the folder where the example is located
|
||||
value: ./examples/crypto/keys
|
||||
value: ./keys
|
|
@ -0,0 +1,10 @@
|
|||
version: 1
|
||||
common:
|
||||
daprdLogDestination: console
|
||||
apps:
|
||||
- appID: crypto-example
|
||||
appDirPath: ./
|
||||
daprGRPCPort: 35002
|
||||
logLevel: debug
|
||||
command: [ "cargo", "run", "--example", "crypto" ]
|
||||
resourcesPath: ./components
|
|
@ -40,7 +40,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
assert_eq!(String::from_utf8(decrypted).unwrap().as_str(), "Test");
|
||||
|
||||
let image = fs::read("./examples/crypto/image.png").unwrap();
|
||||
println!("Successfully Decrypted String");
|
||||
|
||||
let image = fs::read("./image.png").unwrap();
|
||||
|
||||
let encrypted = client
|
||||
.encrypt(
|
||||
|
@ -70,5 +72,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
assert_eq!(decrypted, image);
|
||||
|
||||
println!("Successfully Decrypted Image");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue