| Crates.io | ncr-crypto |
| lib.rs | ncr-crypto |
| version | 0.2.0 |
| created_at | 2022-10-20 18:22:54.290204+00 |
| updated_at | 2023-01-11 19:10:53.412428+00 |
| description | A library for the cryptography used in the Minecraft No-Chat-Reports Mod |
| homepage | |
| repository | https://github.com/JorianWoltjer/ncr-crypto |
| max_upload_size | |
| id | 692795 |
| size | 15,887 |
The cryptography used to generate passwords and encrypted messages exactly as the No Chat Reports Mod for Minecraft does.
use ncr_encryption::{decrypt_with_passphrase, decode_and_verify};
let passphrase = b"secret"; // Setting in NCR
// "Hello, world!" sent as a message in chat:
let ciphertext = base64::decode("q2JCS/M3yMnz+MtXDn4dd6xyqN94Dao=").unwrap();
let decrypted = decrypt_with_passphrase(&ciphertext, passphrase);
let decoded = decode_and_verify(&decrypted);
assert_eq!(decoded, Ok("#%Hello, world!"))
From reading the Source Code on Github it becomes clear how the mod does encryption:
PBKDF2WithHmacSHA1 with a hardcoded salt and 65536 iterations to make your passphrase
into a hash of 16 bytes. This process takes the longestAES-CFB8 encryption"#%" is added as a prefix to the message before encrypting)Decrypting then is very similar, just in reverse:
"#%", the rest is printed decrypted in the chatBy default fastpbkdf2 doesn't compile for Windows, see here
This crate will use ring by default on Windows which is slower than fastpbkdf2, see here
If you're concerned with performance it is recommended to use the Windows Subsystem for Linux.