MagicCrypt is a Java/PHP/NodeJS/Rust library to encrypt/decrpyt strings, files, or data, using Data Encryption Standard(DES) or Advanced Encryption Standard(AES) algorithms. It supports CBC block cipher mode, PKCS5 padding and 64, 128, 192 or 256-bits key length.
```rust
use magic_crypt::MagicCryptTrait;
let mut mc = newmagiccrypt!("magickey", 256);
let base64 = mc.encryptstrto_base64("http://magiclen.org");
assert_eq!("DS/2U8royDnJDiNY2ps3f6ZoTbpZo8ZtUGYLGEjwLDQ=", base64);
asserteq!("http://magiclen.org", mc.decryptbase64tostring(&base64).unwrap()); ```
The default buffer size for the encrypt_reader_to_writer
method and the decrypt_reader_to_writer
method is 4096 bytes. If you want to change that, you can use the encrypt_reader_to_writer2
method or the decrypt_reader_to_writer2
method, and define a length explicitly.
For example, to change the buffer size to 256 bytes,
```rust
extern crate base64;
use std::io::Cursor;
use magiccrypt::MagicCryptTrait; use magiccrypt::generic_array::typenum::U256;
let mut mc = newmagiccrypt!("magickey", 256);
let mut reader = Cursor::new("http://magiclen.org"); let mut writer = Vec::new();
mc.encryptreaderto_writer2::
let base64 = base64::encode(&writer);
assert_eq!("DS/2U8royDnJDiNY2ps3f6ZoTbpZo8ZtUGYLGEjwLDQ=", base64);
asserteq!("http://magiclen.org", mc.decryptbase64tostring(&base64).unwrap()); ```
Disable the default features to compile this crate without std.
toml
[dependencies.magic-crypt]
version = "*"
default-features = false
https://crates.io/crates/magic-crypt
https://docs.rs/magic-crypt
Refer to https://github.com/magiclen/MagicCrypt.
Refer to https://github.com/magiclen/MagicCrypt.
Refer to https://github.com/magiclen/node-magiccrypt.
Please check out our web page at
https://magiclen.org/aes/