Skip to content

Instantly share code, notes, and snippets.

@thgoebel
Created November 4, 2021 22:49
Show Gist options
  • Save thgoebel/27a549b7f9d5408d22e4708c6298f0b3 to your computer and use it in GitHub Desktop.
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
[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"
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