pub fn encrypt(input: &str, key: i32) -> Result<String, &'static str>
Expand description
Encrypts a string using the rail fence cipher.
§Arguments
input
- The string to encryptkey
- The number of rails to use
§Example
use rail_fence_cipher::encrypt;
let plaintext = String::from("Hello, world!");
let ciphertext = encrypt(&plaintext, 4).unwrap();
assert_eq!(ciphertext, "H !e,wdloollr");
§Errors
-
Input must not be empty
- If the input string is empty -
Key must be greater than 0
- If the key is less than 1 -
Error in fence creation
- If there is an error in the fence creation