atagen

matrix-rust-sdk

public
Star0
Watch0
ssh://brewery@pls.lobotomise.me:33/atagen/matrix-rust-sdk.git

Blame: crates/matrix-sdk-qrcode/README.md

7ff8adafe9e4atagen2026-10-22 12:30 UTC1
**matrix-sdk-qrcode** is a crate to easily generate and parse QR codes for
7ff8adafe9e4atagen2026-10-22 12:30 UTC2
interactive verification using [QR codes] in Matrix.
7ff8adafe9e4atagen2026-10-22 12:30 UTC3
7ff8adafe9e4atagen2026-10-22 12:30 UTC4
## Usage
7ff8adafe9e4atagen2026-10-22 12:30 UTC5
7ff8adafe9e4atagen2026-10-22 12:30 UTC6
This is probably not the crate you are looking for, it's used internally in the
7ff8adafe9e4atagen2026-10-22 12:30 UTC7
[matrix-sdk].
7ff8adafe9e4atagen2026-10-22 12:30 UTC8
7ff8adafe9e4atagen2026-10-22 12:30 UTC9
If you still want to play with QR codes, here is a helpful example.
7ff8adafe9e4atagen2026-10-22 12:30 UTC10
7ff8adafe9e4atagen2026-10-22 12:30 UTC11
### Encode into a QR code
7ff8adafe9e4atagen2026-10-22 12:30 UTC12
7ff8adafe9e4atagen2026-10-22 12:30 UTC13
```rust,no_run
7ff8adafe9e4atagen2026-10-22 12:30 UTC14
use matrix_sdk_qrcode::{QrVerificationData, DecodingError};
7ff8adafe9e4atagen2026-10-22 12:30 UTC15
use image::Luma;
7ff8adafe9e4atagen2026-10-22 12:30 UTC16
7ff8adafe9e4atagen2026-10-22 12:30 UTC17
fn main() -> Result<(), DecodingError> {
7ff8adafe9e4atagen2026-10-22 12:30 UTC18
    let data = b"MATRIX\
7ff8adafe9e4atagen2026-10-22 12:30 UTC19
        \x02\x02\x00\x07\
7ff8adafe9e4atagen2026-10-22 12:30 UTC20
        FLOW_ID\
7ff8adafe9e4atagen2026-10-22 12:30 UTC21
        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\
7ff8adafe9e4atagen2026-10-22 12:30 UTC22
        BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\
7ff8adafe9e4atagen2026-10-22 12:30 UTC23
        SHARED_SECRET";
7ff8adafe9e4atagen2026-10-22 12:30 UTC24
7ff8adafe9e4atagen2026-10-22 12:30 UTC25
    let data = QrVerificationData::from_bytes(data)?;
7ff8adafe9e4atagen2026-10-22 12:30 UTC26
    let encoded = data.to_qr_code().unwrap();
7ff8adafe9e4atagen2026-10-22 12:30 UTC27
    let image = encoded.render::<Luma<u8>>().build();
7ff8adafe9e4atagen2026-10-22 12:30 UTC28
7ff8adafe9e4atagen2026-10-22 12:30 UTC29
    Ok(())
7ff8adafe9e4atagen2026-10-22 12:30 UTC30
}
7ff8adafe9e4atagen2026-10-22 12:30 UTC31
```
7ff8adafe9e4atagen2026-10-22 12:30 UTC32
7ff8adafe9e4atagen2026-10-22 12:30 UTC33
[matrix-sdk]: https://github.com/matrix-org/matrix-rust-sdk/
7ff8adafe9e4atagen2026-10-22 12:30 UTC34
[QR codes]: https://spec.matrix.org/unstable/client-server-api/#qr-codes