Files
matrix-rust-sdk/matrix_qrcode
Damir Jelić b95ebe444e
CI / Check style (push) Failing after 32s
CI / Run clippy (push) Has been skipped
CI / linux / WASM (push) Has been skipped
CI / linux / appservice / stable / warp (push) Has been skipped
CI / macOS / appservice / stable / warp (push) Has been skipped
CI / linux / appservice / stable / actix (push) Has been skipped
CI / macOS / appservice / stable / actix (push) Has been skipped
CI / linux / features-markdown (push) Has been skipped
CI / linux / features-socks (push) Has been skipped
CI / linux / features-sso_login (push) Has been skipped
CI / linux / features-no-sled (push) Has been skipped
CI / linux / features-sled_cryptostore (push) Has been skipped
CI / linux / features-no-encryption-and-sled (push) Has been skipped
CI / linux / features-require_auth_for_profile_requests (push) Has been skipped
CI / linux / features-no-encryption (push) Has been skipped
CI / linux / features-rustls-tls (push) Has been skipped
CI / linux / beta (push) Has been skipped
CI / linux / stable (push) Has been skipped
CI / macOS / stable (push) Has been skipped
matrix-sdk: Bump our versions
2021-06-22 14:57:46 +02:00
..
2021-06-17 11:04:17 +02:00
2021-06-22 14:57:46 +02:00
2021-06-22 14:20:25 +02:00

Build Status codecov License #matrix-rust-sdk

matrix-qrcode

matrix-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-rust-sdk.

If you still want to play with QR codes, here are a couple of helpful examples.

Decode an image

use image;
use matrix_qrcode::{QrVerificationData, DecodingError};

fn main() -> Result<(), DecodingError> {
    let image = image::open("/path/to/my/image.png").unwrap();
    let result = QrVerificationData::from_image(image)?;

    Ok(())
}

Encode into a QR code

use matrix_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(())
}

License

Apache-2.0