Enhances the encryption key with account info, similar to the login codes. Prepares the account when scnaning the pairing code on the secondary device. This way, only the passwords needs to be provided, afterwards everything is set up automatically. Closes #150.
26 lines
992 B
Plaintext
26 lines
992 B
Plaintext
@using QRCoder
|
|
<img style="image-rendering:pixelated;image-rendering:-moz-crisp-edges;min-width:@(Size)px;min-height:@(Size)px" src="data:image/png;base64,@(GetBase64(Data))" class="@CssClass" alt="@Data" />
|
|
|
|
@code {
|
|
[Parameter, EditorRequired]
|
|
public string Data { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public int Size { get; set; } = 256;
|
|
|
|
[Parameter(CaptureUnmatchedValues = true)]
|
|
public Dictionary<string, object>? InputAttributes { get; set; }
|
|
|
|
private static readonly QRCodeGenerator QrGenerator = new();
|
|
|
|
private string GetBase64(string data)
|
|
{
|
|
var qrCodeData = QrGenerator.CreateQrCode(data, QRCodeGenerator.ECCLevel.Q);
|
|
var qrCode = new PngByteQRCode(qrCodeData);
|
|
var bytes = qrCode.GetGraphic(5, [0, 0, 0, 255], [0xf5, 0xf5, 0xf7, 255]);
|
|
return Convert.ToBase64String(bytes);
|
|
}
|
|
|
|
private string CssClass => $"qr-code {(InputAttributes?.ContainsKey("class") is true ? InputAttributes["class"] : "")}".Trim();
|
|
}
|