Cleaning+comments.
[rup.git] / src / crypto.rs
index 7e707d0..f415fa1 100644 (file)
@@ -33,8 +33,7 @@ fn decode_key(key: &str) -> Result<Vec<u8>, KeyError> {
 }\r
 \r
 /// Encrypt the given text with the given key. The key length must be 128 bits encoded in base64.\r
-/// Ouput format:\r
-/// Format "1" + base_64(<IV> + <hash(message)> + <aes(message)>)\r
+/// Ouput format: "1" + base_64(<IV> + <hash(message)> + <aes(message)>)\r
 /// IV: 16 bytes randomized.\r
 /// Mode : CBC.\r
 pub fn encrypt(key: &str, plain_text: &str) -> Result<String, EncryptError> {\r
@@ -59,7 +58,8 @@ pub fn encrypt(key: &str, plain_text: &str) -> Result<String, EncryptError> {
     Ok(String::from("1") + &base64::encode(&result))\r
 }\r
 \r
-/// TODO: return a Result<string, DecryptError>\r
+/// Decrypt the given text with the given key. The key length must be 128 bits encoded in base64.\r
+/// Input format: "1" + base_64(<IV> + <hash(message)> + <aes(message)>)\r
 pub fn decrypt(key: &str, cipher_text: &str) -> Result<String, DecryptError> {\r
     let key_as_bytes = decode_key(key).map_err(|e| DecryptError::KeyError(e))?;\r
 \r