-
Notifications
You must be signed in to change notification settings - Fork 544
Expand file tree
/
Copy pathlib.rs
More file actions
18 lines (16 loc) · 938 Bytes
/
lib.rs
File metadata and controls
18 lines (16 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/// While the problem description indicates a return status of 1 should be returned on errors,
/// it is much more common to return a `Result`, so we provide an error type for the result here.
#[derive(Debug, Eq, PartialEq)]
pub enum AffineCipherError {
NotCoprime(i32),
}
/// Encodes the plaintext using the affine cipher with key (`a`, `b`). Note that, rather than
/// returning a return code, the more common convention in Rust is to return a `Result`.
pub fn encode(plaintext: &str, a: i32, b: i32) -> Result<String, AffineCipherError> {
todo!("Encode {plaintext} with the key ({a}, {b})");
}
/// Decodes the ciphertext using the affine cipher with key (`a`, `b`). Note that, rather than
/// returning a return code, the more common convention in Rust is to return a `Result`.
pub fn decode(ciphertext: &str, a: i32, b: i32) -> Result<String, AffineCipherError> {
todo!("Decode {ciphertext} with the key ({a}, {b})");
}