Add documentation for confid
This commit is contained in:
parent
0c17e706ba
commit
369b8b04bc
1 changed files with 14 additions and 0 deletions
|
@ -1,3 +1,13 @@
|
||||||
|
//! Code to generate a Confirmation ID for a given Installation ID
|
||||||
|
//!
|
||||||
|
//! ## History
|
||||||
|
//! The algorithm this uses was originally provided to the UMSKT project by diamondggg.
|
||||||
|
//! The history provided by diamondggg is that they are the originator of the code
|
||||||
|
//! and was created in tandem with an acquaintance who knows number theory.
|
||||||
|
//! The file dates suggest this code was written sometime in 2017/2018.
|
||||||
|
//!
|
||||||
|
//! The Rust version of the code was created by running the original through C2Rust
|
||||||
|
//! and then manually fixing up the result.
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
mod black_box;
|
mod black_box;
|
||||||
|
@ -18,6 +28,10 @@ pub enum ConfirmationIdError {
|
||||||
Unlucky,
|
Unlucky,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Generates a confirmation ID from the given installation ID
|
||||||
|
///
|
||||||
|
/// # Arguments
|
||||||
|
/// * `installation_id` - A string with 7 groups of 6 digits, with or without hyphens
|
||||||
pub fn generate(installation_id: &str) -> Result<String, ConfirmationIdError> {
|
pub fn generate(installation_id: &str) -> Result<String, ConfirmationIdError> {
|
||||||
if installation_id.len() < 54 {
|
if installation_id.len() < 54 {
|
||||||
return Err(ConfirmationIdError::TooShort);
|
return Err(ConfirmationIdError::TooShort);
|
||||||
|
|
Loading…
Add table
Reference in a new issue