// create "user" with insert
- function setUser($username, $key = "", $ttype="HOTP") {
+ function setUser($username, $ttype="HOTP", $key = "") {
if($key == "") $key = $this->createBase32Key();
$hkey = $this->helperb322hex($key);
// TODO: change this to a pattern match for an actual key
if(!isset($token["tokenkey"])) return false;
if($token["tokenkey"] == "") return false;
+ return true;
}
// oddity in the google authenticator... hotp needs to be lowercase.
$data = $this->internalGetData($user);
$toktype = $data["tokentype"];
- $key = $data["tokenkey"];
+ $key = $this->helperhex2b32($data["tokenkey"]);
$toktype = strtolower($toktype);
if($toktype == "hotp") {
$url = "otpauth://$toktype/$user?secret=$key&counter=1";
return $key;
}
+
+ // returns a hex key
+ function getKey($username) {
+ $data = $this->internalGetData($username);
+ $key = $data["tokenkey"];
+
+ return $key;
+ }
+
+ // get key type
+ function getTokenType($username) {
+ $data = $this->internalGetData($username);
+ $toktype = $data["tokentype"];
+ return $toktype;
+ }
+
function helperb322hex($b32) {
$alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";