bhcli

A TUI for chatting on LE PHP Chats (onion)
git clone https://git.dasho.dev/n0tr1v/bhcli.git
Log | Files | Refs | README

commit 8323debadc128fff8c5defd07c9a624cdf3dc56f
parent b68e89fad08bc98b13db772df5cd57e05a36fb3f
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Thu, 30 Mar 2023 02:18:32 -0700

cleanup

Diffstat:
Msrc/lechatphp/mod.rs | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/lechatphp/mod.rs b/src/lechatphp/mod.rs @@ -105,17 +105,18 @@ pub fn solve_b64(b64_str: &str) -> Option<String> { } fn _solve_difficulty1(img: &DynamicImage) -> Option<String> { + let nb_chars = 5; let left_padding = 5; let top_padding = 7; let letter_width = 8; let letter_height = 14; let mut answer = String::new(); - for i in 0..5 { + for i in 0..nb_chars { let sub_img = img.crop_imm(left_padding + ((letter_width+1)*i), top_padding, letter_width, letter_height); let mut buf = vec![]; { let mut enc = image::codecs::gif::GifEncoder::new(&mut buf); - enc.encode(sub_img.as_bytes(), 8, 14, ColorType::Rgba8).ok()?; + enc.encode(sub_img.as_bytes(), letter_width, letter_height, ColorType::Rgba8).ok()?; } let letter_b64 = general_purpose::STANDARD.encode(&buf); let letter_b64 = letter_b64.strip_prefix(B64_PREFIX)?; @@ -131,12 +132,13 @@ fn _solve_difficulty1(img: &DynamicImage) -> Option<String> { } fn solve_difficulty2(img: &DynamicImage) -> Option<String> { + let nb_chars = 5; let left_padding = 5; let top_padding = 7; let letter_width = 8; let letter_height = 14; let mut answer = String::new(); - for i in 0..5 { + for i in 0..nb_chars { let sub_img = img.crop_imm(left_padding + ((letter_width+1)*i), top_padding, letter_width, letter_height); for c in ALPHABET1.chars() { let good_letter_img = get_letter_img(c);