Major release: update image encoding format, mappings, and docs

This commit is contained in:
viraladmin 2026-04-18 13:40:48 -06:00
parent 84b23b7cbb
commit d6cceacfcb
11 changed files with 442 additions and 591 deletions

View File

@ -1,9 +1,9 @@
[package] [package]
name = "encrypted_images" name = "encrypted_images"
version = "1.3.0" version = "1.4.0"
edition = "2021" edition = "2021"
description = "Encrypt Text to Images and decrypt text from images." description = "Encrypt Text to Images and decrypt text from images."
authors = ["Bruce Bates | https://encryptedimages.art"] authors = ["Bruce Bates | https://www.linkedin.com/in/bruce-bates/"]
license = "MIT" license = "MIT"
[dependencies] [dependencies]

142
README.md

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,3 @@
Support this developers open source efforts: Support this developers open source efforts:
bitcoin: bc1pf0s98gva7la6r9srepywwr4llqea8t0r4fj8qkdqqac0f9y5624sxpsmqq bitcoin: bc1q0j2a6e40hkf4lewdu6fuedpzwkrsp5f3rr9mke
ethereum: 0x78046716a783B94240ff6b4Ba6580F6D5690423A
cardano: addr1q8dxlqu824ghzn3extm8zjqzmr2u5fy4p0jpaqs6w8jpt4wkpgtm6wkc0me3gmgfgdadnpzdcj24yz3znme5w7kvm8vs0thea2
solana: HG1fpdqHkxSUyT85V6LGu8dbC3BK4JixiivjYLHVsazQ
tezos: tz2TL7ke3xyxWi4JbS6egscmpEP9Z9XrV86y

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,8 +1,8 @@
use encrypted_images::decryption::text::decrypts; use encrypted_images::decryption::text::decrypts;
fn main() { fn main() {
let encrypted_text = "OWFNTGpvaGFMbWtTUkE9PcjB/klKI3ix+Z0uVuYbd3zRqaTjMgxotQu4hz1FRSfPWRQMOBhLSI6+KFPl8qldeCPoUYvezvVMOScWll9OzCA="; let encrypted_text = "VkdocGN5QnBjeUJoSUE9PfWVW6oF5BuJoZd8kJL1WUjpAMl3ViM+6y9MqKKDpi3TXncUNV1BoyQhxXgoFUSOV7E2hJGhPfvtLb1NtrEk4zs=";
let key = Some("16characterslong"); let key = Some("your_secret_key");
if let Some(decrypted_text) = decrypts(encrypted_text, key) { if let Some(decrypted_text) = decrypts(encrypted_text, key) {
println!("Decrypted text: {}", decrypted_text); println!("Decrypted text: {}", decrypted_text);
} else { } else {

View File

@ -1,5 +1,5 @@
use encrypted_images::encryption::text::encrypts;
use encrypted_images::encryption::images::create_img; use encrypted_images::encryption::images::create_img;
use encrypted_images::encryption::text::encrypts;
fn main() { fn main() {
let key = Some("your_secret_key"); let key = Some("your_secret_key");

View File

@ -2,7 +2,7 @@
fn main() { fn main() {
let plaintext = "This Is Plain Text"; let plaintext = "This Is Plain Text";
let key = Some("16characterslong"); let key = Some("your_secret_key");
let strength = Some("advanced"); let strength = Some("advanced");
let encrypted_text = encrypts(plaintext, key, strength).unwrap(); let encrypted_text = encrypts(plaintext, key, strength).unwrap();
println!("Encrypted text: {}", encrypted_text); println!("Encrypted text: {}", encrypted_text);

View File

@ -1,149 +1,105 @@
pub mod mappings { pub mod mappings {
use std::collections::HashMap; use std::collections::HashMap;
const BASE_MAPPINGS: &[(char, (u8, u8, u8))] = &[
('a', (204, 180, 194)),
('A', (255, 255, 255)),
('b', (197, 186, 201)),
('B', (221, 206, 212)),
('c', (181, 185, 193)),
('C', (184, 201, 223)),
('d', (224, 218, 192)),
('D', (185, 191, 195)),
('e', (181, 197, 198)),
('E', (193, 206, 255)),
('f', (252, 193, 211)),
('F', (183, 192, 229)),
('g', (180, 191, 192)),
('G', (187, 219, 189)),
('h', (195, 187, 234)),
('H', (182, 216, 189)),
('i', (197, 183, 248)),
('I', (200, 182, 204)),
('j', (255, 235, 196)),
('J', (194, 186, 228)),
('k', (199, 238, 239)),
('K', (208, 247, 234)),
('l', (244, 214, 189)),
('L', (187, 243, 239)),
('m', (188, 231, 238)),
('M', (187, 197, 227)),
('n', (186, 240, 191)),
('N', (187, 198, 206)),
('o', (205, 193, 184)),
('O', (191, 187, 197)),
('p', (194, 200, 206)),
('P', (195, 183, 229)),
('q', (182, 219, 196)),
('Q', (238, 216, 184)),
('r', (199, 181, 208)),
('R', (239, 231, 198)),
('s', (189, 188, 230)),
('S', (242, 192, 230)),
('t', (199, 199, 199)),
('T', (188, 190, 230)),
('u', (230, 180, 253)),
('U', (241, 247, 247)),
('v', (242, 190, 199)),
('V', (230, 247, 234)),
('w', (197, 186, 249)),
('W', (194, 247, 249)),
('x', (242, 182, 246)),
('X', (188, 222, 193)),
('y', (188, 194, 183)),
('Y', (197, 195, 197)),
('z', (187, 249, 240)),
('Z', (233, 231, 242)),
('0', (195, 184, 218)),
('1', (232, 180, 196)),
('2', (191, 193, 196)),
('3', (185, 186, 186)),
('4', (191, 247, 180)),
('5', (187, 199, 248)),
('6', (248, 198, 184)),
('7', (243, 195, 184)),
('8', (232, 192, 208)),
('9', (239, 197, 183)),
('/', (199, 187, 241)),
('+', (195, 216, 223)),
('=', (193, 211, 184)),
];
fn vivid_color((r, g, b): (u8, u8, u8)) -> (u8, u8, u8) {
let rf = r as f32;
let gf = g as f32;
let bf = b as f32;
let avg = (rf + gf + bf) / 3.0;
let saturation_boost = 2.35_f32;
let contrast_boost = 1.12_f32;
let lift = -18.0_f32;
let apply = |value: f32| -> u8 {
let saturated = avg + ((value - avg) * saturation_boost);
let contrasted = ((saturated - 128.0) * contrast_boost) + 128.0 + lift;
contrasted.clamp(0.0, 255.0).round() as u8
};
(apply(rf), apply(gf), apply(bf))
}
pub(crate) fn get_color(char: char) -> Option<(u8, u8, u8)> { pub(crate) fn get_color(char: char) -> Option<(u8, u8, u8)> {
match char { BASE_MAPPINGS
'a' => Some((204, 180, 194)),
'A' => Some((255, 255, 255)),
'b' => Some((197, 186, 201)),
'B' => Some((221, 206, 212)),
'c' => Some((181, 185, 193)),
'C' => Some((184, 201, 223)),
'd' => Some((224, 218, 192)),
'D' => Some((185, 191, 195)),
'e' => Some((181, 197, 198)),
'E' => Some((193, 206, 255)),
'f' => Some((252, 193, 211)),
'F' => Some((183, 192, 229)),
'g' => Some((180, 191, 192)),
'G' => Some((187, 219, 189)),
'h' => Some((195, 187, 234)),
'H' => Some((182, 216, 189)),
'i' => Some((197, 183, 248)),
'I' => Some((200, 182, 204)),
'j' => Some((255, 235, 196)),
'J' => Some((194, 186, 228)),
'k' => Some((199, 238, 239)),
'K' => Some((208, 247, 234)),
'l' => Some((244, 214, 189)),
'L' => Some((187, 243, 239)),
'm' => Some((188, 231, 238)),
'M' => Some((187, 197, 227)),
'n' => Some((186, 240, 191)),
'N' => Some((187, 198, 206)),
'o' => Some((205, 193, 184)),
'O' => Some((191, 187, 197)),
'p' => Some((194, 200, 206)),
'P' => Some((195, 183, 229)),
'q' => Some((182, 219, 196)),
'Q' => Some((238, 216, 184)),
'r' => Some((199, 181, 208)),
'R' => Some((239, 231, 198)),
's' => Some((189, 188, 230)),
'S' => Some((242, 192, 230)),
't' => Some((199, 199, 199)),
'T' => Some((188, 190, 230)),
'u' => Some((230, 180, 253)),
'U' => Some((241, 247, 247)),
'v' => Some((242, 190, 199)),
'V' => Some((230, 247, 234)),
'w' => Some((197, 186, 249)),
'W' => Some((194, 247, 249)),
'x' => Some((242, 182, 246)),
'X' => Some((188, 222, 193)),
'y' => Some((188, 194, 183)),
'Y' => Some((197, 195, 197)),
'z' => Some((187, 249, 240)),
'Z' => Some((233, 231, 242)),
'0' => Some((195, 184, 218)),
'1' => Some((232, 180, 196)),
'2' => Some((191, 193, 196)),
'3' => Some((185, 186, 186)),
'4' => Some((191, 247, 180)),
'5' => Some((187, 199, 248)),
'6' => Some((248, 198, 184)),
'7' => Some((243, 195, 184)),
'8' => Some((232, 192, 208)),
'9' => Some((239, 197, 183)),
'/' => Some((199, 187, 241)),
'+' => Some((195, 216, 223)),
'=' => Some((193, 211, 184)),
_ => None,
}
}
pub(crate) fn numbers_to_letter(r: u8, g: u8, b: u8) -> Option<char> {
let color_map: HashMap<(u8, u8, u8), char> = [
((204, 180, 194), 'a'),
((255, 255, 255), 'A'),
((197, 186, 201), 'b'),
((221, 206, 212), 'B'),
((181, 185, 193), 'c'),
((184, 201, 223), 'C'),
((224, 218, 192), 'd'),
((185, 191, 195), 'D'),
((181, 197, 198), 'e'),
((193, 206, 255), 'E'),
((252, 193, 211), 'f'),
((183, 192, 229), 'F'),
((180, 191, 192), 'g'),
((187, 219, 189), 'G'),
((195, 187, 234), 'h'),
((182, 216, 189), 'H'),
((197, 183, 248), 'i'),
((200, 182, 204), 'I'),
((255, 235, 196), 'j'),
((194, 186, 228), 'J'),
((199, 238, 239), 'k'),
((208, 247, 234), 'K'),
((244, 214, 189), 'l'),
((187, 243, 239), 'L'),
((188, 231, 238), 'm'),
((187, 197, 227), 'M'),
((186, 240, 191), 'n'),
((187, 198, 206), 'N'),
((205, 193, 184), 'o'),
((191, 187, 197), 'O'),
((194, 200, 206), 'p'),
((195, 183, 229), 'P'),
((182, 219, 196), 'q'),
((238, 216, 184), 'Q'),
((199, 181, 208), 'r'),
((239, 231, 198), 'R'),
((189, 188, 230), 's'),
((242, 192, 230), 'S'),
((199, 199, 199), 't'),
((188, 190, 230), 'T'),
((230, 180, 253), 'u'),
((241, 247, 247), 'U'),
((242, 190, 199), 'v'),
((230, 247, 234), 'V'),
((197, 186, 249), 'w'),
((194, 247, 249), 'W'),
((242, 182, 246), 'x'),
((188, 222, 193), 'X'),
((188, 194, 183), 'y'),
((197, 195, 197), 'Y'),
((187, 249, 240), 'z'),
((233, 231, 242), 'Z'),
((195, 184, 218), '0'),
((232, 180, 196), '1'),
((191, 193, 196), '2'),
((185, 186, 186), '3'),
((191, 247, 180), '4'),
((187, 199, 248), '5'),
((248, 198, 184), '6'),
((243, 195, 184), '7'),
((232, 192, 208), '8'),
((239, 197, 183), '9'),
((199, 187, 241), '/'),
((195, 216, 223), '+'),
((193, 211, 184), '='),
]
.iter() .iter()
.cloned() .find(|(mapped_char, _)| *mapped_char == char)
.map(|(_, color)| vivid_color(*color))
}
pub(crate) fn numbers_to_letter(r: u8, g: u8, b: u8) -> Option<char> {
let color_map: HashMap<(u8, u8, u8), char> = BASE_MAPPINGS
.iter()
.map(|(ch, color)| (vivid_color(*color), *ch))
.collect(); .collect();
match color_map.get(&(r, g, b)) {
Some(&letter) => Some(letter), color_map.get(&(r, g, b)).copied()
None => None,
}
} }
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long