7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 1 | **matrix-sdk-qrcode** is a crate to easily generate and parse QR codes for |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 2 | interactive verification using [QR codes] in Matrix. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 3 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 4 | ## Usage |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 5 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 6 | This is probably not the crate you are looking for, it's used internally in the |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 7 | [matrix-sdk]. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 8 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 9 | If you still want to play with QR codes, here is a helpful example. |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 10 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 11 | ### Encode into a QR code |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 12 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 13 | ```rust,no_run |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 14 | use matrix_sdk_qrcode::{QrVerificationData, DecodingError}; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 15 | use image::Luma; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 16 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 17 | fn main() -> Result<(), DecodingError> { |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 18 | let data = b"MATRIX\ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 19 | \x02\x02\x00\x07\ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 20 | FLOW_ID\ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 21 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 22 | BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 23 | SHARED_SECRET"; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 24 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 25 | let data = QrVerificationData::from_bytes(data)?; |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 26 | let encoded = data.to_qr_code().unwrap(); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 27 | let image = encoded.render::<Luma<u8>>().build(); |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 28 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 29 | Ok(()) |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 30 | } |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 31 | ``` |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 32 | |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 33 | [matrix-sdk]: https://github.com/matrix-org/matrix-rust-sdk/ |
7ff8adafe9e4 | atagen | 2026-10-22 12:30 UTC | 34 | [QR codes]: https://spec.matrix.org/unstable/client-server-api/#qr-codes |