Skip to content

Conversation

RCasatta
Copy link

@RCasatta RCasatta commented Apr 4, 2020

I need to generate qr codes for data up to 10kb or so, thus I need to split those with the structured append mode, I did a quick test but this need the method push_number_checked to be exposed

#[test]
    fn test_structured_append() {
        // from example https://segno.readthedocs.io/en/stable/structured-append.html#structured-append
        let data = "I read the news today oh boy".as_bytes();
        let data_half = "I read the new".as_bytes();
        let parity = data.iter().fold(0u8, |acc, &x| acc ^ x);
        let mut bits = Bits::new(Version::Normal(1));
        bits.push_mode_indicator(ExtendedMode::StructuredAppend).unwrap();
        bits.push_number_checked(4, 0).unwrap();  // first element of the sequence
        bits.push_number_checked(4, 1).unwrap();  // total length of the sequence (means 2)
        bits.push_number_checked(8, parity as usize).unwrap();  //parity of the complete data
        bits.push_byte_data(data_half).unwrap();
        bits.push_terminator(EcLevel::L).unwrap();
        assert_eq!(hex::encode(bits.clone().into_bytes()), "3013940e49207265616420746865206e657700");  // raw bytes of the first qr code of the example
    }

@RCasatta
Copy link
Author

@kennytm any news on these?

thanks

@danieleades
Copy link

Also interested in using structured append to split a file across multiple QrCodes

@RCasatta
Copy link
Author

RCasatta commented Mar 7, 2021

@danieleades I did a fork https://github.com/RCasatta/qr_code if you are interested

@ivnsch ivnsch mentioned this pull request Jul 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants