Expand description
§No Chat Reports (NCR) Chat Encryption
This crate implements the No Chat Reports’s custom chat encryption. More specifically this implements a fork of No Chat Reports.
Currently all functionalities of the custom chat encryption are implemented. You can still use this crate normally if you are using the original No Chat Reports.
§Examples
§Encrypting
use ncr::{
encoding::Base64rEncoding,
encryption::{Cfb8Encryption, Encryption},
utils::prepend_header,
AesKey,
};
let key = AesKey::gen_from_passphrase(b"secret");
let plaintext = prepend_header("I love Minecraft!");
let ciphertext = Cfb8Encryption::<Base64rEncoding>::encrypt(&plaintext, &key).unwrap();
println!("{}", ciphertext);
§Decrypting
use ncr::{
encoding::Base64rEncoding,
encryption::{Cfb8Encryption, Encryption},
utils::trim_header,
AesKey,
};
let key = AesKey::gen_from_passphrase(b"secret");
let ciphertext = r#"%[2_0»³"!7).«?;!.$¥`¶:8~667ª¸[¬)¢+¤^"#;
let plaintext = Cfb8Encryption::<Base64rEncoding>::decrypt(ciphertext, &key).unwrap();
let plaintext = trim_header(&plaintext).unwrap();
assert_eq!(plaintext, "I love Minecraft!");
§Features
Current there are 4 feature flags.
passphrase
(default): Enable key generation from passphrase.cfb8
: Enable aes/cfb8 encryption.ecb
: Enable aes/ecb encryption.gcm
: Enable aes/gcm encryption.
§How NCR encrypt chat messages
- Two characters
#%
will be prepended to every message. - The string is fed into one of the encryption algorithms.
- The encrypted bytes are fed into one of the encoding algorithms to turn them into sendable Minecraft messages.
The reversal is done on decryption.
Modules§
- encoding
- Some common encoding algorithms.
- encryption
- Some common encryption algorithms.
- utils
- Some common utility functions.
Structs§
- AesKey
- Aes key for encryption (128 bits).
Enums§
- NcrError
- This represents all errors that can happen in this crate.