Created
November 4, 2021 22:49
-
-
Save thgoebel/27a549b7f9d5408d22e4708c6298f0b3 to your computer and use it in GitHub Desktop.
Adhoc script to inspect bytes of encoded data in EU DCC QR Codes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "barcode-inspector" | |
version = "0.1.0" | |
authors = ["Thore"] | |
edition = "2018" | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |
[dependencies] | |
bardecoder = "0.3.0" | |
image = "0.23" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use bardecoder; | |
use image; | |
// Get QR codes from here: | |
// https://github.com/admin-ch/CovidCertificate-App-Android/issues/306 | |
fn main() { | |
let valid = image::open("valid.png").unwrap(); | |
let invalid = image::open("invalid.png").unwrap(); | |
let decoder = bardecoder::default_decoder(); | |
let results_valid = decoder.decode(&valid); | |
let results_invalid = decoder.decode(&invalid); | |
println!("Valid:"); | |
for r in results_valid { | |
let string = r.unwrap(); | |
println!("String: {}", string); | |
println!("Bytes: {:?}", string.as_bytes()); | |
} | |
println!("Invalid:"); | |
for r in results_invalid { | |
let string = r.unwrap(); | |
println!("String: {}", string); | |
println!("Bytes: {:?}", string.as_bytes()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment