     Serial.println("SD card has no key.txt");
     return;
   }
+  String keyString = "";
   while (keyFile.available()) {
     char ch = keyFile.read();
     if (ch == ' ' || ch == '\n') continue;
-    key.concat(ch);
+    keyString.concat(ch);
   }
   keyFile.close();
+  uint8_t keyText[33];
+  keyString.toCharArray((char*)keyText, 33);
+  base32_decode(keyText, key, 20);
 
   // Set up the keyboard
   Keyboard.begin();

  } else if (command == "set time") {
    setTime();
  } else if (command == "key") {
    Serial.println(key);
  }
}


#include <DS3231.h>
#include <SPI.h>
#include <SD.h>
#include <sha1.h>

#define BUTTON_PIN 42
#define SD_PIN 4
#define KEY_FILE "key.txt"
#define INTERVAL 30
#define TOKEN_LENGTH 6

DS3231 rtc(SDA, SCL);
uint8_t key[20];
int previousButtonState = HIGH;

// Gets a UNIX timestamp from the RTC
