Skip to content

Commit 901d84a

Browse files
committed
feat: v2.2.9
1 parent 08ca572 commit 901d84a

File tree

12 files changed

+17
-91
lines changed

12 files changed

+17
-91
lines changed

Cargo.lock

Lines changed: 1 addition & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bin-encrypt-decrypt"
3-
version = "2.2.8"
3+
version = "2.2.9"
44
edition = "2021"
55
authors = ["ltpp-universe <root@ltpp.vip>"]
66
license = "MIT"
@@ -9,12 +9,6 @@ keywords = ["binaryencryption", "decryption", "customcharset", "highperformance"
99
repository = "https://github.com/ltpp-universe/bin-crypt-decrypt"
1010
categories = ["cryptography", "encoding"]
1111

12-
[dependencies]
13-
std-macro-extensions = "0.21.1"
14-
15-
[dev-dependencies]
16-
color-output = "6.1.8"
17-
1812
[profile.dev]
1913
incremental = false
2014
opt-level = 3

src/crypt_decrypt/cfg.rs

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
use crate::*;
2-
use color_output::*;
3-
use std_macro_extensions::*;
42

53
#[test]
64
fn test_crypt_decrypt() {
75
let mut crypt_decrypt: CryptDecrypt<'_> = CryptDecrypt::new();
86
let test_str: &str = "test";
9-
let mut charset: String = string!("");
7+
let mut charset: String = String::new();
108
for i in 0..26 {
119
let ch: char = ('a' as u8 + i) as char;
1210
charset.push(ch);
@@ -23,45 +21,5 @@ fn test_crypt_decrypt() {
2321
crypt_decrypt.charset(&charset);
2422
let encode: Result<String, CryptError> = crypt_decrypt.encrypt(test_str);
2523
let decode: Result<String, DecryptError> = crypt_decrypt.decrypt(&encode.clone().unwrap());
26-
let encode_str: String = encode.clone().unwrap();
27-
let decode_str: String = decode.clone().unwrap();
28-
OutputListBuilder::new()
29-
.add(
30-
OutputBuilder::new()
31-
.endl(true)
32-
.text(&format!("charset: {}", charset))
33-
.bg_color(ColorType::Use(Color::Blue))
34-
.color(ColorType::Use(Color::Yellow))
35-
.blod(true)
36-
.build(),
37-
)
38-
.add(
39-
OutputBuilder::new()
40-
.endl(true)
41-
.text(&format!("test word: {}", test_str))
42-
.bg_color(ColorType::Use(Color::Yellow))
43-
.color(ColorType::Use(Color::Blue))
44-
.blod(true)
45-
.build(),
46-
)
47-
.add(
48-
OutputBuilder::new()
49-
.endl(true)
50-
.text(&format!("encode_str: {}", encode_str))
51-
.bg_color(ColorType::Use(Color::Cyan))
52-
.color(ColorType::Use(Color::Yellow))
53-
.blod(true)
54-
.build(),
55-
)
56-
.add(
57-
OutputBuilder::new()
58-
.endl(true)
59-
.text(&format!("decode_str: {}", decode_str))
60-
.bg_color(ColorType::Use(Color::Green))
61-
.color(ColorType::Use(Color::Yellow))
62-
.blod(true)
63-
.build(),
64-
)
65-
.run();
6624
assert_eq!(decode.unwrap(), test_str);
6725
}

src/crypt_decrypt/error.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use super::r#static::CHARSET_LEN;
2-
use std::fmt;
1+
use crate::*;
32

43
#[derive(Debug, Clone)]
54
pub enum CryptError {

src/crypt_decrypt/impl.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
use super::error::{CryptError, DecryptError};
2-
use super::r#static::CHARSET_LEN;
3-
use super::r#type::CryptDecrypt;
4-
use crate::decrypt::decrypt::decrypt;
5-
use crate::encrypt::encrypt::encrypt;
6-
use std_macro_extensions::*;
1+
use crate::*;
72

83
impl<'a> Default for CryptDecrypt<'a> {
94
#[inline]
@@ -25,7 +20,7 @@ impl<'a> CryptDecrypt<'a> {
2520
/// Returns `true` if `charset` contains `CHARSET_LEN` unique characters, otherwise returns `false`.
2621
#[inline]
2722
pub(crate) fn judge_charset_safe(charset: &str) -> bool {
28-
let mut hash_set: HashSet<char> = hash_set!();
23+
let mut hash_set: HashSet<char> = HashSet::new();
2924
for tmp_char in charset.chars() {
3025
hash_set.insert(tmp_char);
3126
}

src/crypt_decrypt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
mod cfg;
33
pub(crate) mod error;
44
pub(crate) mod r#impl;
5-
mod r#static;
5+
pub(crate) mod r#static;
66
pub(crate) mod r#type;

src/crypt_decrypt/static.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pub(super) static CHARSET_LEN: usize = 64;
1+
pub static CHARSET_LEN: usize = 64;

src/decrypt/cfg.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
use crate::*;
2-
use std_macro_extensions::*;
32

43
#[test]
54
fn test_decrypt() {
6-
let test_str: &str = "test";
7-
let mut charset: String = string!("");
5+
let mut charset: String = String::new();
86
for i in 0..26 {
97
let ch: char = ('a' as u8 + i) as char;
108
charset.push(ch);

src/decrypt/decrypt.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::*;
2-
use std_macro_extensions::*;
32

43
/// Decrypts a given encoded string based on a specified charset, using 4-character
54
/// groups to restore the original bytes. Each character in the `decode_str` string
@@ -28,8 +27,8 @@ pub fn decrypt(charset: &str, decode_str: &str) -> Result<String, DecryptError>
2827
if !CryptDecrypt::judge_charset_safe(charset) {
2928
return Err(DecryptError::CharsetError);
3029
}
31-
let mut buffer: Vec<u8> = vector!();
32-
let mut decoded: Vec<u8> = vector!();
30+
let mut buffer: Vec<u8> = Vec::new();
31+
let mut decoded: Vec<u8> = Vec::new();
3332
for ch in decode_str.chars() {
3433
if let Some(idx) = charset.chars().position(|c| c == ch) {
3534
buffer.push(idx as u8);

src/encrypt/cfg.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
use crate::*;
2-
use std_macro_extensions::*;
32

43
#[test]
54
fn test_decrypt() {
6-
let test_str: &str = "test";
7-
let mut charset: String = string!("");
5+
let mut charset: String = String::new();
86
for i in 0..26 {
97
let ch: char = ('a' as u8 + i) as char;
108
charset.push(ch);

0 commit comments

Comments
 (0)