Skip to content

Commit c962ad7

Browse files
committed
feat: rename
1 parent 901d84a commit c962ad7

File tree

16 files changed

+97
-94
lines changed

16 files changed

+97
-94
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[package]
2-
name = "bin-encrypt-decrypt"
3-
version = "2.2.9"
2+
name = "bin-encode-decode"
3+
version = "0.0.1"
44
edition = "2021"
55
authors = ["ltpp-universe <root@ltpp.vip>"]
66
license = "MIT"
7-
description = "A high-performance binary encryption and decryption library that supports customizable character sets beyond Base64."
8-
keywords = ["binaryencryption", "decryption", "customcharset", "highperformance", "base64alternative"]
9-
repository = "https://github.com/ltpp-universe/bin-crypt-decrypt"
10-
categories = ["cryptography", "encoding"]
7+
description = "A high-performance binary encode and decode library that supports customizable character sets beyond Base64."
8+
keywords = ["binaryencode", "decode", "customcharset", "highperformance", "base64alternative"]
9+
repository = "https://github.com/ltpp-universe/bin-crypt-decode"
10+
categories = ["encoding"]
1111

1212
[profile.dev]
1313
incremental = false

readme.md

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,81 @@
11
<center>
22

3-
# bin-encrypt-decrypt
3+
# bin-encode-decode
44

5-
[![](https://img.shields.io/crates/v/bin-encrypt-decrypt.svg)](https://crates.io/crates/bin-encrypt-decrypt)
6-
[![](https://docs.rs/bin-encrypt-decrypt/badge.svg)](https://docs.rs/bin-encrypt-decrypt)
7-
[![](https://github.com/ltpp-universe/bin-encrypt-decrypt/workflows/Rust/badge.svg)](https://github.com/ltpp-universe/bin-encrypt-decrypt/actions?query=workflow:Rust)
8-
[![](https://img.shields.io/crates/l/bin-encrypt-decrypt.svg)](./LICENSE)
5+
[![](https://img.shields.io/crates/v/bin-encode-decode.svg)](https://crates.io/crates/bin-encode-decode)
6+
[![](https://docs.rs/bin-encode-decode/badge.svg)](https://docs.rs/bin-encode-decode)
7+
[![](https://github.com/ltpp-universe/bin-encode-decode/workflows/Rust/badge.svg)](https://github.com/ltpp-universe/bin-encode-decode/actions?query=workflow:Rust)
8+
[![](https://img.shields.io/crates/l/bin-encode-decode.svg)](./LICENSE)
99

1010
</center>
1111

12-
[Official Documentation](https://docs.ltpp.vip/BIN-ENCRYPT-DECRYPT/)
12+
[Official Documentation](https://docs.ltpp.vip/bin-encode-decode/)
1313

14-
A high-performance binary encryption and decryption library that supports customizable character sets beyond Base64.
14+
A high-performance binary encode and decode library that supports customizable character sets beyond Base64.
1515

1616
## Features
1717

1818
- **Custom Character Sets**: Define your own character set for encoding and decoding, allowing for flexible data representation.
1919
- **High Performance**: Optimized for speed, making it suitable for applications requiring efficient cryptographic operations.
20-
- **Simple API**: Intuitive and easy-to-use interface for both encryption and decryption processes.
20+
- **Simple API**: Intuitive and easy-to-use interface for both encode and decode processes.
2121
- **Robust Error Handling**: Provides clear and descriptive error messages to facilitate debugging.
2222
- **Extensive Documentation**: Comprehensive guides and examples to help you get started quickly.
2323

2424
## Installation
2525

26-
To install `bin-encrypt-decrypt` run cmd:
26+
To install `bin-encode-decode` run cmd:
2727

2828
```sh
29-
cargo add bin-encrypt-decrypt
29+
cargo add bin-encode-decode
3030
```
3131

3232
## Usage
3333

34-
### Encrypt
34+
### encode
3535

3636
#### Use Struct
3737

3838
```rust
39-
use bin_encrypt_decrypt::*;
40-
let mut crypt_decrypt: CryptDecrypt<'_> = CryptDecrypt::new();
39+
use bin_encode_decode::*;
40+
let mut en_decode: Endecode<'_> = Endecode::new();
4141
let test_str: &str = "test";
4242
let mut charset: String = String::from("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=");
43-
crypt_decrypt.charset(&charset);
44-
let encode: Result<String, CryptError> = crypt_decrypt.encrypt(test_str);
43+
en_decode.charset(&charset);
44+
let encode: Result<String, EncodeError> = en_decode.encode(test_str);
4545
```
4646

4747
#### Use Function
4848

4949
```rust
50-
use bin_encrypt_decrypt::*;
50+
use bin_encode_decode::*;
5151
let test_str: &str = "test";
5252
let mut charset: String = String::from("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=");
53-
let encode: Result<String, CryptError> = encrypt(&charset, test_str);
53+
let encode: Result<String, EncodeError> = encode(&charset, test_str);
5454
```
5555

56-
### Decrypt
56+
### decode
5757

5858
#### Use Struct
5959

6060
```rust
61-
use bin_encrypt_decrypt::*;
62-
let mut crypt_decrypt: CryptDecrypt<'_> = CryptDecrypt::new();
61+
use bin_encode_decode::*;
62+
let mut en_decode: Endecode<'_> = Endecode::new();
6363
let test_str: &str = "aab0aabLaabZaab0";
6464
let mut charset: String = String::from("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=");
65-
crypt_decrypt.charset(&charset);
66-
let decode: Result<String, DecryptError> = crypt_decrypt.decrypt(test_str);
65+
en_decode.charset(&charset);
66+
let decode: Result<String, DecodeError> = en_decode.decode(test_str);
6767
```
6868

6969
#### Use Function
7070

7171
```rust
72-
use bin_encrypt_decrypt::*;
73-
let test_str: &str = "aab0aabLaabZaab0";
74-
let mut charset: String = String::from("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=");
75-
let decode: Result<String, DecryptError> = decrypt(&charset, test_str);
72+
use bin_encode_decode::*;
73+
let charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=";
74+
let encoded_str = "aab0aabLaabZaab0";
75+
let decoded_str = decode(charset, encoded_str);
76+
let charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_=";
77+
let original_str = "test";
78+
let encoded_str = encode(charset, original_str);
7679
```
7780

7881
## License
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::*;
22

33
#[test]
4-
fn test_crypt_decrypt() {
5-
let mut crypt_decrypt: CryptDecrypt<'_> = CryptDecrypt::new();
4+
fn test_crypt_decode() {
5+
let mut en_decode: Endecode<'_> = Endecode::new();
66
let test_str: &str = "test";
77
let mut charset: String = String::new();
88
for i in 0..26 {
@@ -18,8 +18,8 @@ fn test_crypt_decrypt() {
1818
charset.push(ch);
1919
}
2020
charset.push_str("_=");
21-
crypt_decrypt.charset(&charset);
22-
let encode: Result<String, CryptError> = crypt_decrypt.encrypt(test_str);
23-
let decode: Result<String, DecryptError> = crypt_decrypt.decrypt(&encode.clone().unwrap());
21+
en_decode.charset(&charset);
22+
let encode: Result<String, EncodeError> = en_decode.encode(test_str);
23+
let decode: Result<String, DecodeError> = en_decode.decode(&encode.clone().unwrap());
2424
assert_eq!(decode.unwrap(), test_str);
2525
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
use crate::*;
22

33
#[derive(Debug, Clone)]
4-
pub enum CryptError {
4+
pub enum EncodeError {
55
CharsetError,
66
}
77

8-
impl fmt::Display for CryptError {
8+
impl fmt::Display for EncodeError {
99
#[inline]
1010
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1111
match self {
12-
CryptError::CharsetError => write!(f, "CryptError: Charset is invalid. Please ensure the charset contains exactly {} unique characters.",CHARSET_LEN ),
12+
EncodeError::CharsetError => write!(f, "EncodeError: Charset is invalid. Please ensure the charset contains exactly {} unique characters.",CHARSET_LEN ),
1313
}
1414
}
1515
}
1616

1717
#[derive(Debug, Clone)]
18-
pub enum DecryptError {
18+
pub enum DecodeError {
1919
CharsetError,
2020
}
2121

22-
impl fmt::Display for DecryptError {
22+
impl fmt::Display for DecodeError {
2323
#[inline]
2424
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2525
match self {
26-
DecryptError::CharsetError => write!(f, "CryptError: Charset is invalid. Please ensure the charset contains exactly {} unique characters.", CHARSET_LEN),
26+
DecodeError::CharsetError => write!(f, "DecodeError: Charset is invalid. Please ensure the charset contains exactly {} unique characters.", CHARSET_LEN),
2727
}
2828
}
2929
}
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
use crate::*;
22

3-
impl<'a> Default for CryptDecrypt<'a> {
3+
impl<'a> Default for Endecode<'a> {
44
#[inline]
55
fn default() -> Self {
6-
CryptDecrypt { charset: "" }
6+
Endecode { charset: "" }
77
}
88
}
99

10-
impl<'a> CryptDecrypt<'a> {
11-
/// Creates a new instance of `CryptDecrypt` with a default charset.
10+
impl<'a> Endecode<'a> {
11+
/// Creates a new instance of `Endecode` with a default charset.
1212
#[inline]
1313
pub fn new() -> Self {
14-
CryptDecrypt::default()
14+
Endecode::default()
1515
}
1616

1717
/// Checks if the `charset` contains `CHARSET_LEN` unique characters.
@@ -30,7 +30,7 @@ impl<'a> CryptDecrypt<'a> {
3030
true
3131
}
3232

33-
/// Sets the `charset` for the current `CryptDecrypt` instance, if it is not already set.
33+
/// Sets the `charset` for the current `Endecode` instance, if it is not already set.
3434
///
3535
/// # Parameters
3636
/// - `charset`: A string slice representing the charset to be used.
@@ -42,34 +42,34 @@ impl<'a> CryptDecrypt<'a> {
4242
where
4343
'b: 'a,
4444
{
45-
if self.charset != CryptDecrypt::default().charset {
45+
if self.charset != Endecode::default().charset {
4646
return self;
4747
}
4848
self.charset = charset;
4949
self
5050
}
5151

52-
/// Encrypts a string based on the current `charset`.
52+
/// encodes a string based on the current `charset`.
5353
///
5454
/// # Parameters
55-
/// - `encode_str`: The string slice to be encrypted.
55+
/// - `encode_str`: The string slice to be encodeed.
5656
///
5757
/// # Returns
58-
/// Returns a `Result` containing the encrypted `String` if successful, or a `CryptError` if the charset is invalid.
58+
/// Returns a `Result` containing the encodeed `String` if successful, or a `EncodeError` if the charset is invalid.
5959
#[inline]
60-
pub fn encrypt(&self, encode_str: &str) -> Result<String, CryptError> {
61-
encrypt(self.charset, encode_str)
60+
pub fn encode(&self, encode_str: &str) -> Result<String, EncodeError> {
61+
encode(self.charset, encode_str)
6262
}
6363

64-
/// Decrypts a string based on the current `charset`.
64+
/// decodes a string based on the current `charset`.
6565
///
6666
/// # Parameters
67-
/// - `decode_str`: The string slice to be decrypted.
67+
/// - `decode_str`: The string slice to be decodeed.
6868
///
6969
/// # Returns
70-
/// Returns a `Result` containing the decrypted `String` if successful, or a `DecryptError` if the charset is invalid.
70+
/// Returns a `Result` containing the decodeed `String` if successful, or a `DecodeError` if the charset is invalid.
7171
#[inline]
72-
pub fn decrypt(&self, decode_str: &str) -> Result<String, DecryptError> {
73-
decrypt(self.charset, decode_str)
72+
pub fn decode(&self, decode_str: &str) -> Result<String, DecodeError> {
73+
decode(self.charset, decode_str)
7474
}
7575
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/// Represents a struct for handling both encryption and decryption of strings
1+
/// Represents a struct for handling both encode and decode of strings
22
/// using a custom character set (`charset`). This struct provides methods to
3-
/// encrypt and decrypt strings based on the provided `charset`.
3+
/// encode and decode strings based on the provided `charset`.
44
///
55
/// # Fields
66
/// - `charset`: A reference to the character set used for encoding and decoding.
@@ -9,8 +9,8 @@
99
///
1010
/// # Lifetimes
1111
/// - `'a`: The lifetime `'a` is associated with `charset`, ensuring that the `charset` reference
12-
/// lives at least as long as the `CryptDecrypt` instance.
12+
/// lives at least as long as the `Endecode` instance.
1313
#[derive(Debug, Clone)]
14-
pub struct CryptDecrypt<'a> {
14+
pub struct Endecode<'a> {
1515
pub(crate) charset: &'a str,
1616
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::*;
22

33
#[test]
4-
fn test_decrypt() {
4+
fn test_decode() {
55
let mut charset: String = String::new();
66
for i in 0..26 {
77
let ch: char = ('a' as u8 + i) as char;
@@ -16,6 +16,6 @@ fn test_decrypt() {
1616
charset.push(ch);
1717
}
1818
charset.push_str("_=");
19-
let encode_res: Result<String, DecryptError> = decrypt(&charset, "aab0aabLaabZaab0");
19+
let encode_res: Result<String, DecodeError> = decode(&charset, "aab0aabLaabZaab0");
2020
assert_eq!(encode_res.unwrap(), "test");
2121
}

0 commit comments

Comments
 (0)