Skip to content

Moonlight-Companies/rust_voicecode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

voicecode

voice code hasher for Produce Traceability Initiative (PTI) labels

Reference: https://producetraceability.org/voice-pick-code-calculator/

This struct is used to store all parts of the input to be hashed and resulting output.

Be aware that the example impl returns case sensitive results so be careful if your Lot Code could be mixed case.

Example for GTIN 123456789012 and Lot LOT123 with pack date 2003-01-02

let voice_code = HashVoiceCode::new("123456789012", "LOT123", "01", "02", "03").unwrap();
println!("Voice Code: {}", voice_code.voice_code); // expects 8812
println!("Minor: {}", voice_code.voice_code_minor); // expects 88
println!("Major: {}", voice_code.voice_code_major); // expects 12
if let Some(date) = chrono::NaiveDate::from_ymd_opt(2003, 1, 2) {
    let voice_code = HashVoiceCode::new_naive("123456789012", "LOT123", date);
    println!("Voice Code: {}", voice_code.voice_code); // expects 8812
    println!("Minor: {}", voice_code.voice_code_minor); // expects 88
    println!("Major: {}", voice_code.voice_code_major); // expects 12
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages