Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/azzamsa/nrot
Simple letter substitution cipher 🔐
https://github.com/azzamsa/nrot
decryption encryption rot13
Last synced: 6 days ago
JSON representation
Simple letter substitution cipher 🔐
- Host: GitHub
- URL: https://github.com/azzamsa/nrot
- Owner: azzamsa
- License: mit
- Created: 2022-07-23T01:11:01.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-12-08T03:43:40.000Z (about 1 year ago)
- Last Synced: 2024-11-16T04:47:37.537Z (about 1 month ago)
- Topics: decryption, encryption, rot13
- Language: Rust
- Homepage:
- Size: 27.3 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
---
## Features
- ROT encryption & decryption
- Exhaustive testing## Usage
```rust
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);
}
```To learn more, see other [examples](examples/).
## Credits
- ROT13 implementation is inspired by [Cameron Phillips's ROT13](https://github.com/cameronp98/rot13)
- [Noto Emoji](https://github.com/googlefonts/noto-emoji)