#minecraft-mod #chat #encryption #reports #base64 #gcm #passphrase

ncr

Rust语言实现Minecraft模组“无聊天报告”(No Chat Reports)的聊天加密

3个版本

0.1.2 2023年5月21日
0.1.1 2023年1月21日
0.1.0 2023年1月13日

#1120密码学

每月24次下载

MIT 协议

43KB
583

无聊天报告(NCR)聊天加密

本包实现了无聊天报告的定制聊天加密。更具体地说,这是无聊天报告的一个分支。

实现了定制聊天加密的所有功能。如果您使用的是原始的无聊天报告,您仍然可以正常使用此包。

  • 凯撒、Ecb、Cfb8和Gcm加密
  • Base64(旧版)、Base64r、Sus16Mc256编码
  • 密码短语

示例

加密

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);

解密

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!");

依赖项

~0.5–0.9MB
~16K SLoC