Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bumping QRCoder from 1.3.5 to 1.3.9 #56

Merged
merged 2 commits into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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