Skip to content

Commit

Permalink
Merge pull request #56 from BrandonPotter/QRCoder-1.3.9
Browse files Browse the repository at this point in the history
Bumping QRCoder from 1.3.5 to 1.3.9
  • Loading branch information
ahwm authored Aug 27, 2020
2 parents 92ad09a + 933b66b commit 589f980
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Google.Authenticator/Google.Authenticator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
<Description>Google Authenticator Two-Factor Authentication Library (Not officially affiliated with Google.)</Description>
<Authors>Brandon Potter</Authors>
<Company>Brandon Potter</Company>
<Version>2.0.1</Version>
<Version>2.0.2</Version>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/BrandonPotter/GoogleAuthenticator</PackageProjectUrl>
<PackageId>GoogleAuthenticator</PackageId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="QRCoder" Version="1.3.5.0" />
<PackageReference Include="QRCoder" Version="1.3.9" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>

Expand Down
32 changes: 16 additions & 16 deletions Google.Authenticator/TwoFactorAuthenticator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ public SetupCode GenerateSetupCode(string issuer, string accountTitleNoSpaces, b
}

string qrCodeUrl = string.Empty;
if (generateQrCode)
{
using (QRCodeGenerator qrGenerator = new QRCodeGenerator())
using (QRCodeData qrCodeData = qrGenerator.CreateQrCode(provisionUrl, QRCodeGenerator.ECCLevel.Q))
using (QRCode qrCode = new QRCode(qrCodeData))
using (Bitmap qrCodeImage = qrCode.GetGraphic(QRPixelsPerModule))
using (MemoryStream ms = new MemoryStream())
{
qrCodeImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png);

qrCodeUrl = String.Format("data:image/png;base64,{0}", Convert.ToBase64String(ms.ToArray()));
if (generateQrCode)
{
using (QRCodeGenerator qrGenerator = new QRCodeGenerator())
using (QRCodeData qrCodeData = qrGenerator.CreateQrCode(provisionUrl, QRCodeGenerator.ECCLevel.Q))
using (QRCode qrCode = new QRCode(qrCodeData))
using (Bitmap qrCodeImage = qrCode.GetGraphic(QRPixelsPerModule))
using (MemoryStream ms = new MemoryStream())
{
qrCodeImage.Save(ms, System.Drawing.Imaging.ImageFormat.Png);

qrCodeUrl = String.Format("data:image/png;base64,{0}", Convert.ToBase64String(ms.ToArray()));
}
}

Expand Down Expand Up @@ -129,7 +129,7 @@ internal string GenerateHashedCode(byte[] key, long iterationNumber, int digits
}

HMACSHA1 hmac = new HMACSHA1(key);

byte[] hash = hmac.ComputeHash(counter);

int offset = hash[hash.Length - 1] & 0xf;
Expand All @@ -154,7 +154,7 @@ private long GetCurrentCounter(DateTime now, DateTime epoch, int timeStep)
{
return (long)(now - epoch).TotalSeconds / timeStep;
}

public bool ValidateTwoFactorPIN(string accountSecretKey, string twoFactorCodeFromClient)
{
return ValidateTwoFactorPIN(accountSecretKey, twoFactorCodeFromClient, DefaultClockDriftTolerance);
Expand All @@ -170,10 +170,10 @@ public string GetCurrentPIN(string accountSecretKey)
{
return GeneratePINAtInterval(accountSecretKey, GetCurrentCounter());
}
public string GetCurrentPIN(string accountSecretKey,DateTime now)

public string GetCurrentPIN(string accountSecretKey, DateTime now)
{
return GeneratePINAtInterval(accountSecretKey, GetCurrentCounter(now,_epoch,30));
return GeneratePINAtInterval(accountSecretKey, GetCurrentCounter(now, _epoch, 30));
}

public string[] GetCurrentPINs(string accountSecretKey)
Expand Down

0 comments on commit 589f980

Please sign in to comment.