/// <summary> /// Retrieves / generates a QR code to be displayed to the user for sharing the shared secret and easy input /// of this code by scanning with a specified size. /// </summary> /// <param name="label">The label to identify which account a key is associated with.</param> /// <param name="secret">The shared secret.</param> /// <param name="size">The desired size, in pixels (width and height equal), of the QR code.</param> /// <returns>Returns an image encoded as data uri.</returns> /// <see href="https://en.wikipedia.org/wiki/Data_URI_scheme"/> /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="size"/> is less than 0</exception> public string GetQrCodeImageAsDataUri(string label, string secret, int size) { if (size <= 0) { throw new ArgumentOutOfRangeException(nameof(size)); } return("data:" + QrCodeProvider.GetMimeType() + ";base64," + Convert.ToBase64String(QrCodeProvider.GetQrCodeImage(GetQrText(label, secret), size))); }
/// <summary> /// Retrieves / generates a QR code to be displayed to the user for sharing the shared secret and easy input /// of this code by scanning with a specified size. /// </summary> /// <param name="label">The label to identify which account a key is associated with.</param> /// <param name="secret">The shared secret.</param> /// <param name="size">The desired size, in pixels (width and height equal), of the QR code.</param> /// <returns>Returns an image encoded as data uri.</returns> /// <see href="https://en.wikipedia.org/wiki/Data_URI_scheme"/> /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="size"/> is less than 0</exception> #pragma warning disable CA1055 // Uri return values should not be strings public string GetQrCodeImageAsDataUri(string label, string secret, int size) #pragma warning restore CA1055 // Uri return values should not be strings { if (size <= 0) { throw new ArgumentOutOfRangeException(nameof(size)); } return("data:" + QrCodeProvider.GetMimeType() + ";base64," + Convert.ToBase64String(QrCodeProvider.GetQrCodeImage(GetQrText(label, secret), size))); }