otp.c
changeset 56 a573346e6f7b
parent 55 0aaf56a96d21
child 57 4974e5368a29
--- a/otp.c	Sun Jun 18 01:57:23 2017 -0400
+++ b/otp.c	Sun Jun 18 19:40:30 2017 -0400
@@ -3,6 +3,7 @@
 #include <string.h>
 #include <time.h>
 #include "sha1.h"
+#include "otp.h"
 
 static int base32_decode(const char *src, const int srclen, uint8_t *dst, const int dstlen)
 {
@@ -56,7 +57,7 @@
     return retval;
 }
 
-static int totp(const char *base32_secret, char *dst, int dstlen)
+int totp(const char *base32_secret, char *dst, int dstlen)
 {
     uint8_t decoded[64];
     int decodedlen;
@@ -88,21 +89,5 @@
     return 0;
 }
 
-int main(int argc, char **argv)
-{
-    char result[16];
-    int i;
-    for (i = 1; i < argc; i++) {
-        printf("%s: ", argv[i]);
-        if (totp(argv[i], result, sizeof (result)) == -1) {
-            printf("[FAILED!]");
-        } else {
-            printf("%s (valid for %d more seconds)", result, 30 - ((int) (time(NULL) % 30)));
-        }
-        printf("\n");
-    }
-    return 0;
-}
-
 /* end of otp.c ... */