Skip to content

Commit

Permalink
Merge pull request #104 from BrandonPotter/feature/Net60Release
Browse files Browse the repository at this point in the history
v2.5 release candidate
  • Loading branch information
ahwm authored Apr 13, 2022
2 parents c464ba3 + 3a48b7b commit 725d5a9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Google.Authenticator/Google.Authenticator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Description>Google Authenticator Two-Factor Authentication Library (Not officially affiliated with Google.)</Description>
<Authors>Brandon Potter</Authors>
<Company>Brandon Potter</Company>
<Version>2.4.0</Version>
<Version>2.5.0</Version>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/BrandonPotter/GoogleAuthenticator</PackageProjectUrl>
<PackageId>GoogleAuthenticator</PackageId>
Expand Down
9 changes: 7 additions & 2 deletions Google.Authenticator/TwoFactorAuthenticator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ public SetupCode GenerateSetupCode(string issuer,
throw new NullReferenceException("Account Title is null");
}

// MS wants us to change this to use EscapeDataString - https://docs.microsoft.com/en-us/dotnet/fundamentals/syslib-diagnostics/syslib0013
// But that changes the output. Specifically "[email protected]" becomes "a%40b.com"
// See issue https://github.com/BrandonPotter/GoogleAuthenticator/issues/103
#pragma warning disable SYSLIB0013
accountTitleNoSpaces = RemoveWhitespace(Uri.EscapeUriString(accountTitleNoSpaces));
#pragma warning restore SYSLIB0013

var encodedSecretKey = Base32Encoding.ToString(accountSecretKey);

var provisionUrl = string.IsNullOrWhiteSpace(issuer)
Expand All @@ -81,7 +87,7 @@ private static string GenerateQrCodeUrl(int qrPixelsPerModule, string provisionU
var qrCodeUrl = "";
try
{
using (var qrGenerator = new QRCodeGenerator())
using (var qrGenerator = new QRCodeGenerator())
using (var qrCodeData = qrGenerator.CreateQrCode(provisionUrl, QRCodeGenerator.ECCLevel.Q))
#if NET6_0
using (var qrCode = new PngByteQRCode(qrCodeData))
Expand All @@ -98,7 +104,6 @@ private static string GenerateQrCodeUrl(int qrPixelsPerModule, string provisionU
qrCodeUrl = $"data:image/png;base64,{Convert.ToBase64String(ms.ToArray())}";
}
#endif

}
catch (TypeInitializationException e)
{
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ TwoFactorAuthenticator tfa = new TwoFactorAuthenticator();
bool result = tfa.ValidateTwoFactorPIN(key, txtCode.Text)
```

## Updates

### 2.5.0
Now runs on .Net 6.0.
Technically the QR Coder library we rely on still does not fully support .Net 6.0 so it is possible there will be other niggling issues, but for now all tests pass for .Net 6.0 on both Windows and Linux.

## Common Pitfalls

* Old documentation indicated specifying width and height for the QR code, but changes in QR generation now uses pixels per module (QR "pixel") so using a value too high will result in a huge image that can overrun memory allocations
Expand Down

0 comments on commit 725d5a9

Please sign in to comment.