#加密解密 #解密 #加密 #rot

nrot

简单的字母替换密码

2个稳定版本

2.0.0 2022年7月23日
1.0.0 2022年7月23日

#1633 in 密码学

Download history 3/week @ 2024-03-08 28/week @ 2024-03-29 8/week @ 2024-04-05 53/week @ 2024-04-26 3/week @ 2024-05-03 28/week @ 2024-05-10 7/week @ 2024-05-17 229/week @ 2024-05-24 209/week @ 2024-05-31

每月363次下载

MIT许可证

10KB
131

nROT

简单字母替换密码 🔐️

Build status Sponsor me

功能

  • ROT加密和解密
  • 全面测试

用法

use nrot::{rot, rot_letter, Mode};

fn encrypt(input: String) {
    let rotation = 13;

    let input_length = input.len();
    let input_bytes = input.as_bytes();

    if input_length == 1 {
        let byte_result = rot_letter(Mode::Encrypt, input_bytes[0], rotation);
        println!("{}", String::from_utf8_lossy(&[byte_result]))
    } else {
        let bytes_result = rot(Mode::Encrypt, input_bytes, rotation);
        println!("{}", String::from_utf8_lossy(&bytes_result))
    };
}

fn decrypt(input: String) {
    let rotation = 13;

    let input_length = input.len();
    let input_bytes = input.as_bytes();

    if input_length == 1 {
        let byte_result = rot_letter(Mode::Decrypt, input_bytes[0], rotation);
        println!("{}", String::from_utf8_lossy(&[byte_result]))
    } else {
        let bytes_result = rot(Mode::Decrypt, input_bytes, rotation);
        println!("{}", String::from_utf8_lossy(&bytes_result))
    };
}

fn main() {
    let input = "Hello, world!".to_string();
    encrypt(input);

    let input = "Uryyb, jbeyq!".to_string();
    decrypt(input);
}

了解更多,请参阅其他示例

致谢

无运行时依赖