From 0584cc756079ea4a4f337269fbfbd705fa4e2d48 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9gory=20Burri?= Date: Wed, 7 Aug 2019 14:51:40 +0200 Subject: [PATCH] Cleaning+comments. --- README.md | 2 +- src/crypto.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4308f25..c50b374 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ * PS> cd vcpkg * PS> .\bootstrap-vcpkg.bat * Install openssl dev livb - * PS> vcpkg install openssl:x64-windows + * PS> .\vcpkg.exe install openssl:x64-windows * Define these env variables: * $env:VCPKG_ROOT= * $env:OPENSSL_DIR=\installed\x64-windows diff --git a/src/crypto.rs b/src/crypto.rs index 7e707d0..f415fa1 100644 --- a/src/crypto.rs +++ b/src/crypto.rs @@ -33,8 +33,7 @@ fn decode_key(key: &str) -> Result, KeyError> { } /// Encrypt the given text with the given key. The key length must be 128 bits encoded in base64. -/// Ouput format: -/// Format "1" + base_64( + + ) +/// Ouput format: "1" + base_64( + + ) /// IV: 16 bytes randomized. /// Mode : CBC. pub fn encrypt(key: &str, plain_text: &str) -> Result { @@ -59,7 +58,8 @@ pub fn encrypt(key: &str, plain_text: &str) -> Result { Ok(String::from("1") + &base64::encode(&result)) } -/// TODO: return a Result +/// Decrypt the given text with the given key. The key length must be 128 bits encoded in base64. +/// Input format: "1" + base_64( + + ) pub fn decrypt(key: &str, cipher_text: &str) -> Result { let key_as_bytes = decode_key(key).map_err(|e| DecryptError::KeyError(e))?; -- 2.43.0