encrypted-images/README.md

351 lines
202 KiB
Markdown
Raw Normal View History

2024-07-16 23:40:41 +00:00
# Encrypted Images
**Author**: Bruce Bates
**Copyright**: 2023
**X**: @thebrucebates
**Website**: [https://encryptedimages.art](https://encryptedimages.art)
## License
Encrypted Images is distributed under the MIT License. [![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
## Installation
```text
#dependancies
encrypted_images: 1.3.0
```
## Table of Contents
1. [Introduction](#introduction)
2. [Supperted Characters and Encryption Information](#supported-characters)
3. [Min and Max Characters Requirements](#min--max-requirements)
4. [Encrypting Text]()
- [Encryption Settings](#encryption-settings)
5. [Decrypting Text]()
6. [Encoding Images](#encoding-images)
- [Styles](#styles)
- [Watermarks](#watermarks)
- [Watermark Settings](#watermark-settings)
- [Gradient Settings](#gradient-settings)
7. [Decoding Images](#decoding-images)
8. [Functions](#functions)
## Introduction
`encrypted_images` is a Rust crate that allows you to perform plainttext to encryption and then into images as well as from encrypted image to cipher text to decrpyted original text. It supports advanced options of security, watermarking, customized gradient outputs, and output positioning styles.
## Supported Characters
The following characters can be used for encryption and decryption:
All UTF 8 characters including but not limited to spaces and special characters.
The library employs an AES-256 with HMAC-SHA-256 encryption to protect characters based on the preferences chosen by the developer.
## Min / Max Requirements
The minimum and maximum allowed string sizes for encryption and decryption
- min: 10 character string
- max: u64 (18,446,744,073,709,551,615 characters)
## Encrypting Text
Encrypting text is a straight forward process.
+ `input` &str: This is the text you want to encrypt. It is protected against timing attacks by default but in its default form is only intended for novelty use where the actual encrpytion process is less important, such as encrypting a wallet address to encode as an image. The data is not sensative so novelty use is accepted. For security, optional perameters should be used.
### Encryption Settings
+ `key` Option<&str>: Our default key is prebuilt into the encryption process. It is only intended for novelty usage. If you are seeking true encrpyted image security this key should be changed to a key of 16 characters in length.
+ `strength` Option<&str>: Because this crate works for both novelty and true encryption, the default strength is not secure.
- default: This setting is the default option if None us used. It allows for novelty usage. This will return the exact same encrypted cipher from the same input every time.
- advanced: Advanced will return a different cipher from the same input every time. This protects against comparison attacks.
## Encoding Images
Image encoding has 9 parameters, 6 are Options. Although you can convert any text to image it must first be base64 encoded. Not encoding to base64 may cause decoding to fail. All options are defined below.
+ `ciphertext` &str: The base64 encoded text you wish to encrypt.
+ `style` &str: The orientation you wish to output the image
+ `watermark` &str: The watermark you wish to use
### Styles
These are the style choices. A style must be selected. For standard usage h should be used.
- h: This is the default upright position of an image. First character of cipher is pixel (0,0)
- h2: This is the image flipped vertically so the bottom row contains cipher. Changes direction of gradient. Firch Character of cipher is pixel (height, 0)
- v: This is the image flipped 90 degrees so the veritical left column contains cipher. Changes direction of gradient. First character of cipher is pixel (0,width)
- v2: This is the image flipped 270 degrees and flipped vertically so the veritical right column contains cipher. Changes direction of gradient. First character of cipher is pixel (0,0)
### Watermarks
These are the choices for watermarks. A watermark must be selected. If you do not wish to use a watermark use the "empty" choice.
- empty: no watermark
- bitcoin: default bitcoin watermark
- ethereum: default ethereum watermark
- cardano: default cardano watermark
- base64 encoded watermark: custom watermark
#### Watermark Settings
When using a custom base64 watermark, these are the optional setting you have. These settings MUST be present when using a custom watermark. They have no effect on default watermarks and should be set to None.
+ `a` Option<u8> (Range 0 - 255): Used to adjust the alpha change of an image. We do this through a very customized method that adjusts the type of alpha based on the image used. In images with transparent background, it only adjusts the alpha change of the background. If the image has no full transparancy as its background, alpha is applied to the image as a whote.
+ `w` Option<u32>: Width of watermark. Should not excede the width of the image. The watermark will always be placed at the center of the image.
+ `h` Option<u32>: Height of watermark. Should not excede the heigth of the image. The watermark will always be placed at the center of the image.
### Gradient Settings
Gradient settings are entirely optional. Configuring them is tricky to manipulate. Each of these values are turned into gradient with out custom gradient formula. Results may not be as expected. If you wish to use the defaults, set these to None.
+ `r` Option<u8> (Range 0 - 255): r represents the first color of the gradient pattern. Understand this represents the "r" of rgb, not an actual color. Play with the r, g and b values to create various unique gradients.
+ `g` Option<u8> (Range 0 - 255): g represents the first color of the gradient pattern. Understand this represents the "g" of rgb, not an actual color. Play with the r, g and b values to create various unique gradients.
+ `b` Option<u8> (Range 0 - 255): b represents the first color of the gradient pattern. Understand this represents the "b" of rgb, not an actual color. Play with the r, g and b values to create various unique gradients.
## Decoding Images
Decoding is straight forword. It only offers a single paramenter. That parameter is the encoded image. The orientation style of the image does not matter as long as as it matches one of the styles from the image encoding process.
`encoded_image` &str:
## Functions
### `encrypts`
Encrypts a text string using AES-128 CBC encryption using novelty settings. This will return the same output form the same input every time.
`run --example encrypt_novelty`
```rust
use encrypted_images::encryption::text::encrypts;
fn main() {
let plaintext = "This Is Plain Text";
let encrypted_text = encrypts(plaintext, None, None).unwrap();
println!("Encrypted text: {}", encrypted_text);
}
```
Encrypts a text string using AES-128 CBC encryption with secure settings.
`cargo run --example encrypt_secure`
```rust
use encrypted_images::encryption::text::encrypts;
fn main() {
let plaintext = "This Is Plain Text";
let key = Some("16characterslong");
let strength = Some("advanced");
let encrypted_text = encrypts(plaintext, key, strength).unwrap();
println!("Encrypted text: {}", encrypted_text);
}
```
### `decrypts`
Decrypts an encrypted text string using AES-128 CBC decryption with novelty settings.
`cargo run --example decrypt_novelty`
```rust
use encrypted_images::decryption::text::decrypts;
fn main() {
let encrypted_text = "VkdocGN5QkpjeUJRYkE9PZNY2MOW01NWpSxCtFG6acHuAWun+CElPQ/IIwd0gy+D+IiBqB/5+qo8Jr9bMBOwoih3amCtjXlkAlRKHX5fhqI=";
if let Some(decrypted_text) = decrypts(encrypted_text, None) {
println!("Decrypted text: {}", decrypted_text);
} else {
println!("Decryption failed.");
}
}
```
Decrypts an encrypted text string using AES-128 CBC decryption with secure settings.
`cargo run --example decrypt_secure`
```rust
use encrypted_images::decryption::text::decrypts;
fn main() {
let encrypted_text = "OWFNTGpvaGFMbWtTUkE9PcjB/klKI3ix+Z0uVuYbd3zRqaTjMgxotQu4hz1FRSfPWRQMOBhLSI6+KFPl8qldeCPoUYvezvVMOScWll9OzCA=";
let key = Some("16characterslong");
if let Some(decrypted_text) = decrypts(encrypted_text, key) {
println!("Decrypted text: {}", decrypted_text);
} else {
println!("Decryption failed.");
}
}
```
### `create_img`
Creates an encoded image.
`cargo run --example create_an_image`
```rust
use encrypted_images::encryption::images::create_img;
fn main() {
let ciphertext = "VkdocGN5QkpjeUJRYkE9PZNY2MOW01NWpSxCtFG6acHuAWun+CElPQ/IIwd0gy+D+IiBqB/5+qo8Jr9bMBOwoih3amCtjXlkAlRKHX5fhqI=";
let style = "h";
let watermark = "bitcoin";
let r = Some(100);
let g = Some(134);
let b = Some(137);
if let Some(encoded_image) = create_img(ciphertext, style, watermark, r, g, b, None, None, None) {
println!("Encoded image: {}", encoded_image);
} else {
println!("Image creation or encoding failed.");
}
}
```
Creates an encoded image with a custom gradient.
`cargo run --example create_an_image_custom_gradient`
```rust
use encrypted_images::encryption::images::create_img;
fn main() {
let ciphertext = "VkdocGN5QkpjeUJRYkE9PZNY2MOW01NWpSxCtFG6acHuAWun+CElPQ/IIwd0gy+D+IiBqB/5+qo8Jr9bMBOwoih3amCtjXlkAlRKHX5fhqI=";
let style = "h";
let watermark = "bitcoin";
let r = Some(46);
let g = Some(115);
let b = Some(82);
if let Some(encoded_image) = create_img(ciphertext, style, watermark, r, g, b, None, None, None) {
println!("Encoded image: {}", encoded_image);
} else {
println!("Image creation or encoding failed.");
}
}
```
Creates an encoded image with custom watermark
`cargo run --example create_an_image_custom_watermark`
```rust
use encrypted_images::encryption::images::create_img;
fn main() {
let ciphertext = "VkdocGN5QkpjeUJRYkE9PZNY2MOW01NWpSxCtFG6acHuAWun+CElPQ/IIwd0gy+D+IiBqB/5+qo8Jr9bMBOwoih3amCtjXlkAlRKHX5fhqI=";
let style = "h";
let watermark = "iVBORw0KGgoAAAANSUhEUgAACqMAAAqjCAYAAACgs6lKAAAACXBIWXMAAAsTAAALEwEAmpwYAAAgAElEQVR42uzau69cVxnG4WMcKaQgJA0EEBIQQxRm5jgkokgBBKhTnpJI3EwVoVDgKJ49mtJtSrcpLVGlNB2GiJJbKMOlgihKFPvMHluyh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EAAACgPTYEkmSMKkkyRgUoxhhVkmSMCgAAAADtsSGQJGNUSZIxKkAx41n/g3HX3zCykiQZowIAAABAO2wIJMkYVZJkjApQ1GTW/9AgVZJkjAoAAAAA7bAhkCRjVEmSMSpAcQapkiRjVAAAAABohw2BJBmjSpKMUQE2wiBVkmSMCgAAAABtsCGQJGNUSZIxKsDGGKRKkoxRAQAAAKB+NgSSZIwqSTJGBdgog1RJkjEqAAAAANTNhkCSjFElScaoABtnkCpJMkYFAAAAgHrZEEiSMaokyRgVYBAMUiVJxqgAAAAAUCcbAkkyRpUkGaMCDIZBqiTJGBUAAAAA6mNDIEnGqJIkY1SAQTFIlSQZowIAAABAXWwIJMkYVZJkjAowOAapkiRjVAAAAACohw2BJBmjSpKMUQEGadz1PzJIlSRjVAAAAABg+GwIJMkYVZJkjAowWAapkmSMCgAAAAAMnw2BJBmjSpKMUQEGzSBVkoxRAQAAAIBhsyGQJGNUSZIxKsDgGaRKkjEqAAAAADBcNgSSZIwqSTJGBaiCQaokGaMCAAAAAMNkQyBJxqiSJGNUgGoYpEqSMSoAAAAAMDw2BJJkjCpJMkYFqIpBqiQZowIAAAAAw2JDIEnGqJIkY1SA6hikSpIxKgAAAAAwHDYEkmSMKk
let r = Some(100);
let g = Some(134);
let b = Some(137);
let a = Some(0);
let w = Some(32);
let h = Some(32);
if let Some(encoded_image) = create_img(ciphertext, style, watermark, r, g, b, a, w, h) {
println!("Encoded image: {}", encoded_image);
} else {
println!("Image creation or encoding failed.");
}
}
```
Creates an image upside down
`cargo run --example create_an_image_upside_down`
```rust
use encrypted_images::encryption::images::create_img;
fn main() {
let ciphertext = "VkdocGN5QkpjeUJRYkE9PZNY2MOW01NWpSxCtFG6acHuAWun+CElPQ/IIwd0gy+D+IiBqB/5+qo8Jr9bMBOwoih3amCtjXlkAlRKHX5fhqI=";
let style = "h2";
let watermark = "bitcoin";
let r = Some(100);
let g = Some(134);
let b = Some(137);
if let Some(encoded_image) = create_img(ciphertext, style, watermark, r, g, b, None, None, None) {
println!("Encoded image: {}", encoded_image);
} else {
println!("Image creation or encoding failed.");
}
}
```
### `decode_image_and_extract_text`
Decode an image and extracts original text from it.
`cargo run --example decode_image`
```rust
use encrypted_images::decryption::images::decode_image_and_extract_text;
fn main() {
let encoded_image = "iVBORw0KGgoAAAANSUhEUgAAAGwAAABsCAYAAACPZlfNAAA3rklEQVR4nO3deWxcW34n9u9dat+ryFpY3JeiJGqhpLfoLXS3uttre2L3xJPxuB0HjoNkepAgHiQzCBIgSJwAGTjOJJ5BkHiWbJ7ECyaDAJN0HMNu9/L6vX79+kmiRFEiRZHFnSyyWFVk7XWrbr7n3kOyROm9fpjpf9jgARqtEsmqOudz7zm/haqnBAffNT0791Bqt+DpuYFSyo2ku4bmsg70FgBzGb7CHezmPoQjM4Kx517kMh24Fx9j72YAsUeDyI0r6Dyeh3PYiajnFvaDDxF8cITmyDiqmgdOVYFurMLwDqL9YB7m7V4E9DhaB1U0nq0AYyOIu3cAbxnlfAwlNYmwaw3G5iX09jqwGK0i0VJgrurojD9EalbF83oT3jf5+L2rqCWz8IWAWovfV7+K7aGniK1cw+7ABzAdExBDM57Dlb2B1ugWQo0+1NseNHJP4U31o7q9wb+PQTOXoO/2w3cURiVQRDO2Dn9ZQb0QQaCdxm6fHwllB2XnPlqOHiSLKeR8B/BWttCshaDGQmgq86g33oTb+z2ohhNeZRp5Zx3hj+egD4asuV1a0rAe0BB161jn2l/yOfl6V9Eq1LBqLCEZu4Zm04CSmEXKOYAV5y4C2QwOJupQAgPvmL7cPRRaLfgIVngJLItA4Q1sS7AJgu0QzLv0BLs3fOgl2M4JmBs9nmnkCBYmWH3kFWAPn8K8GUOIYA0B9nwVGBniawqwKg7zEWtSx2AJgj3tAsP4HFKPVDwjmP91HcZ7V7rA6kjVr2CTYL0E234BbAWe7DU0PhVsGc7dPngIViNY3QLTCBY6AUsR7FCC9RFsx2eDGQSDBfaUYK8T7PsE018JdoVgqwTrIdgqwa4E3Kj4rthgnSXEI8d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j8ZfB1nZgjmgYItiuAMuXgEgIlywwJ9byCo7UJIISbFKC+Vo2WHh8A6l1FR8RrH9Cx/5cH2ruYzA3Ltf78JhgExbYI04wRS5OwygglR3A7ieAmQQzeXHGd71oEMxlgRXgtcBMC6wmwdYI1pZgTyWYvxbimSfAduBsTKDpXSRY2QJrEEz/eJFgHmtud9Y0zLo07ioEK8/bYK0+GyzIC185BlvHlNOHjyXY4QTB9J5b5oAhwBzMqicsMPcLYIcYKowz7+Hkkwm8uenF/GAH/Qe7eDLQwCTB5gmmrmehRsPIeAhIsNEHGrZGel4G28jBHFIwQrBtAVY4AkIBXLHA3MjmTVTUJPdxG+yyBPO0bLDo+BZSmyo+JNjgmI7cfJJX8DGYF1P1JB4RbNICe0ywBLmAtlFCOpvG9ieAKQRr8+JM7rpRI5jHAivBbYG1LbCGBMsSzJRg8xIsSLADCywHd2MMdW5tqnFogbUIpn7MKsqgy5rbnQ0N9x0adxWCVZ/aYI2kDRbm95nHYJu45vTgIwlWniCYFrtpDnUe2GD6mAXmfAGsjJHCKBaaj2HGe/HWthdz/R3mIHt4nK7h8mOCjRJsk4dtOIxLnn7ME2z8oQMbQ1HUCaarXWBbnOyAiTGCbQqwUgUI+HDVAmNAk2+jpibhlWBTEszVssF6xneQ2lbxAcGGR3TsPGUCrh+D+XGtHsfs0FNcXhFgTwjWSy4BdkSwFDY/AUyzwA4JxjIRwXwW2BGcFhiLCgRrSbBl5z6f9xTMTbAwwfYJZij7BBsh2DJggV1Hm2C4zx2o32HN7c6Who81jbsKweqLNliNpbqSAFuG2p6SYNu44XThQ+cewcZRnSCYGp02R/DQBlN5KBNMfwGsirHCMBaMJ2j3xPAOt4yHfR0MH+bxKFXB1BOCDROMk+4Ew7ji6cMcwTJzLqwNhNEkmNoNtnMAM93GBMHWBdhRDfB5cN0C82Mp30JDTcItwa5JMEfLBouP55DaVfFdgo0O6dha7OEiZC
if let Some(extracted_text) = decode_image_and_extract_text(encoded_image) {
println!("Extracted text: {}", extracted_text);
} else {
println!("Image decoding or text extraction failed.");
}
}
```
### Advanced Usage
1: Encrypt and Create Image
`cargo run --example encrypt_and_create_image`
```rust
use encrypted_images::encryption::text::encrypts;
use encrypted_images::encryption::images::create_img;
fn main() {
let key = Some("your_secret_key");
let ciphertext = "This is a secret message.";
let style = "h";
let encrypted = encrypts(ciphertext, key.clone(), None).unwrap();
let watermark = "bitcoin";
let image_data = create_img(&encrypted, style, watermark, None, None, None, None, None, None);
match image_data {
Some(encoded_image) => println!("Encoded Image:\n{}", encoded_image),
None => println!("Failed to create the image."),
}
}
```
2: Decode Image and Decrypt
`cargo run --example decode_image_and_decrypt`
```rust
use encrypted_images::decryption::images::decode_image_and_extract_text;
use encrypted_images::decryption::text::decrypts;
fn main() {
let encoded_image = "iVBORw0KGgoAAAANSUhEUgAAAGwAAABsCAYAAACPZlfNAAA4QElEQVR4nO3cCWxkW3of9v+tfV+4FZcii1uxuDR7ff36db/uWTySxlomkjyyLNtyFFtWAjhQHMAxbMCOk0hAEiNRAmQBLBmCEjuIbdiwDFluy/LzeGY4zfdev252s5trcSkuRbKqyGIVi7Uv9/p/7r1FFl9TM2PLtkCBBxhMo8l363znd+453/kOm9K33v6OEh69i+2SGT1H80gflJEo22EZrgOHfkCaxD3/N/Gi24qRzU4M92fxNGrA47t3MD+ThtO6gLByE8oDP14v23Cz9DtYyN3EQ8cxZt8fwyhOsA4v3n/1r7FYA1LKNEzWdgxb12Hfn8C65UB9RnDsEUqnc7Dt+xC7GULtRQGVh05Mf2sR0a/cxy3I8ORfYmbDgScP7uCj2Tge+qN4Fm9g+sltxL7pQdFzCFt7HfePV/GduoJ7RuAFbqDWtY3e4BhES36yCrvdCWNmEnnjt2E03QAG1yC3yah9asDjL7yP56+WMXUnCMO/iqLQ60P2NI6MpOBul4TF3bu4VXPh+fhnKG8r6DGU1ZgePWiD9GkGL2sxRB6H4X4xhznnVyGfPoOpOgZFqaIytArb1jRQr6njU2zksWgH8jfG4fg4ipFqDW/bHHBJFeDY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qCrRJsnEkQwYb8olo/eg6WtBCsBouPUR26oYHNEazyLthbAbZDsEEo95pgn2DBNqB2aPa9VrCXWOQgpaQQTEYdzNAE20Fw9IYGliLYJMHWCTZBsA2CRTSw/+zGAr48fXHgP9/2shJqp3WsZxUMuCSlvdMktbsUfuVi+923Lvzi39uHsT4MdK9pYGsGPL7RAr
let extracted_text = decode_image_and_extract_text(encoded_image);
match extracted_text {
Some(encrypted_text) => {
let key = Some("your_secret_key"); // Replace with your actual key
let decrypted_text = decrypts(encrypted_text.as_str(), key.clone());
match decrypted_text {
Some(text) => println!("Decrypted Text:\n{}", text),
None => println!("Decryption failed."),
}
}
None => println!("Failed to decode the image and extract text."),
}
}