From db37a32bad8cd009ed7d28d758c995d761dd334c Mon Sep 17 00:00:00 2001 From: viraladmin <00purple@gmail.com> Date: Fri, 13 Oct 2023 14:48:57 -0600 Subject: [PATCH] Update README.md major adjustments to code to add security for encryption, was only added to decryption originally. Also we added the = which was overlooked as its not technically part of the standard base64 libray. --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8cdd3fb..3f09265 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ use encrypted_images::encryption::text::encrypts; let plaintext = "ThisIsPlainText"; let key = Some("YourSecretKey"); let encrypted_text = encrypts(plaintext, key); -println!("Encrypted text: {}", encrypted_text); +println!("Encrypted text: {}", encrypted_text.as_ref().unwrap()); ``` Encrypts a text string using AES-128 CBC encryption without a private key. @@ -49,7 +49,7 @@ Encrypts a text string using AES-128 CBC encryption without a private key. use encrypted_images::encryption::text::encrypts; let plaintext = "ThisIsPlainText"; let encrypted_text = encrypts(plaintext); -println!("Encrypted text: {}", encrypted_text); +println!("Encrypted text: {}", encrypted_text.as_ref().unwrap()); ``` ### `decrypts` @@ -61,7 +61,7 @@ use encrypted_images::decryption::text::decrypts; let encrypted_text = "YourEncryptedText"; let key = Some("YourSecretKey"); -if let Some(decrypted_text) = decrypts(encrypted_text, key) { +if let Some(decrypted_text) = decrypts(encrypted_text.as_ref().unwrap(), key) { println!("Decrypted text: {}", decrypted_text); } else { println!("Decryption failed."); @@ -132,7 +132,7 @@ fn main() { // Create an image from the encrypted text let watermark = "bitcoin"; // Optional watermark text - let image_data = create_img(&encrypted, watermark); + let image_data = create_img(encrypted.as_ref().unwrap(), watermark); match image_data { Some(encoded_image) => println!("Encoded Image:\n{}", encoded_image), @@ -160,7 +160,7 @@ fn main() { let key = Some("your_secret_key"); //optional // Decrypt the extracted text - let decrypted_text = decrypts(&encrypted_text, key.clone()); + let decrypted_text = decrypts(encrypted.as_ref().unwrap(), key.clone()); match decrypted_text { Some(text) => println!("Decrypted Text:\n{}", text), @@ -170,3 +170,4 @@ fn main() { None => println!("Failed to decode the image and extract text."), } } +```