Skip to content

Commit

Permalink
chart.googleapis.com dependency removed
Browse files Browse the repository at this point in the history
  • Loading branch information
bebo-dot-dev committed Dec 4, 2016
1 parent 97d0121 commit df0434a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
18 changes: 9 additions & 9 deletions ESP8266TOTP.cpp
Expand Up @@ -18,13 +18,13 @@

#include "ESP8266TOTP.h"

//RFC 4648 defined 'standard' Base32 base32Alphabet
//RFC4648 defined 'standard' Base32 base32Alphabet
unsigned char ESP8266TOTP::base32Alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";

//Google char QR code uri parts
const char* ESP8266TOTP::googleChartUriPre = "https://chart.googleapis.com/chart?chs=225x225&cht=qr&chl=200x200&chld=M|0&chl=otpauth://totp/user@";
const char* ESP8266TOTP::googleChartUriSecret = "%3Fsecret%3D";
const char* ESP8266TOTP::googleChartUriIssuer = "%26issuer%3D";
//QR code uri parts
const char* ESP8266TOTP::qrCodeUriPre = "otpauth://totp/user@";
const char* ESP8266TOTP::qrCodeUriSecret = "?secret=";
const char* ESP8266TOTP::qrCodeUriIssuer = "&issuer=";

/*
* returns a new secret key of made up of random bytes of TOTP_SECRET_BYTE_COUNT length
Expand Down Expand Up @@ -114,7 +114,7 @@ bool ICACHE_FLASH_ATTR ESP8266TOTP::IsTokenValid(uint64_t epoch, uint8_t* keyByt
}

/*
* returns a Google Authenticator key uri format compatible uri for the given keyBytes
* returns a Google Authenticator key uri for the given keyBytes
* intended for rendering a QR code in a web page.
* https://github.com/google/google-authenticator/wiki/Key-Uri-Format
*
Expand All @@ -132,11 +132,11 @@ String ICACHE_FLASH_ATTR ESP8266TOTP::GetQrCodeImageUri(uint8_t* keyBytes, Strin

char* base32Key = reinterpret_cast<char*>(&data32);

outStr = String(ESP8266TOTP::googleChartUriPre);
outStr = String(ESP8266TOTP::qrCodeUriPre);
outStr += hostname;
outStr += ESP8266TOTP::googleChartUriSecret;
outStr += ESP8266TOTP::qrCodeUriSecret;
outStr += String(base32Key);
outStr += ESP8266TOTP::googleChartUriIssuer;
outStr += ESP8266TOTP::qrCodeUriIssuer;
outStr += issuer;

}
Expand Down
6 changes: 3 additions & 3 deletions ESP8266TOTP.h
Expand Up @@ -45,9 +45,9 @@ class ESP8266TOTP {
static String ICACHE_FLASH_ATTR GetQrCodeImageUri(uint8_t* keyBytes, String hostname, String issuer);
private:
static unsigned char base32Alphabet[];
static const char* googleChartUriPre;
static const char* googleChartUriSecret;
static const char* googleChartUriIssuer;
static const char* qrCodeUriPre;
static const char* qrCodeUriSecret;
static const char* qrCodeUriIssuer;
};

#endif /* ESP8266TOTP_H_ */
4 changes: 2 additions & 2 deletions examples/.settings/org.eclipse.cdt.core.prefs
Expand Up @@ -187,10 +187,10 @@ environment/project/it.baeyens.arduino.core.toolChain.release.249398523/A.EXTRA.
environment/project/it.baeyens.arduino.core.toolChain.release.249398523/A.EXTRA.TIME.DTS/value=0
environment/project/it.baeyens.arduino.core.toolChain.release.249398523/A.EXTRA.TIME.LOCAL/delimiter=\:
environment/project/it.baeyens.arduino.core.toolChain.release.249398523/A.EXTRA.TIME.LOCAL/operation=replace
environment/project/it.baeyens.arduino.core.toolChain.release.249398523/A.EXTRA.TIME.LOCAL/value=1480713463
environment/project/it.baeyens.arduino.core.toolChain.release.249398523/A.EXTRA.TIME.LOCAL/value=1480847472
environment/project/it.baeyens.arduino.core.toolChain.release.249398523/A.EXTRA.TIME.UTC/delimiter=\:
environment/project/it.baeyens.arduino.core.toolChain.release.249398523/A.EXTRA.TIME.UTC/operation=replace
environment/project/it.baeyens.arduino.core.toolChain.release.249398523/A.EXTRA.TIME.UTC/value=1480713463
environment/project/it.baeyens.arduino.core.toolChain.release.249398523/A.EXTRA.TIME.UTC/value=1480847472
environment/project/it.baeyens.arduino.core.toolChain.release.249398523/A.EXTRA.TIME.ZONE/delimiter=\:
environment/project/it.baeyens.arduino.core.toolChain.release.249398523/A.EXTRA.TIME.ZONE/operation=replace
environment/project/it.baeyens.arduino.core.toolChain.release.249398523/A.EXTRA.TIME.ZONE/value=0
Expand Down

0 comments on commit df0434a

Please sign in to comment.