matrix-rust-sdk/crates/matrix-sdk-qrcode
Jonas Platte 12a02f0458 Make examples section name consistent in docs 2023-05-17 14:45:24 +02:00
..
src Make examples section name consistent in docs 2023-05-17 14:45:24 +02:00
Cargo.toml Remove unused dependencies 2023-05-02 15:06:46 +02:00
README.md test(qrcode): Restore `image` only for one test. 2022-09-12 12:42:18 +02:00

README.md

matrix-sdk-qrcode is a crate to easily generate and parse QR codes for interactive verification using QR codes in Matrix.

Usage

This is probably not the crate you are looking for, it's used internally in the matrix-sdk.

If you still want to play with QR codes, here is a helpful example.

Encode into a QR code

use matrix_sdk_qrcode::{QrVerificationData, DecodingError};
use image::Luma;

fn main() -> Result<(), DecodingError> {
    let data = b"MATRIX\
        \x02\x02\x00\x07\
        FLOW_ID\
        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\
        BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\
        SHARED_SECRET";

    let data = QrVerificationData::from_bytes(data)?;
    let encoded = data.to_qr_code().unwrap();
    let image = encoded.render::<Luma<u8>>().build();

    Ok(())
}