When I use the secret key "abcdefghijklmnop" in Google Authenticator (Android), Microsoft Authenticator (Android) and oathtool (Ubuntu 18.04.3 LTS), I get matching Time-based One-Time Password (TOTP) values. Unfortunately, I do not get a matching TOTP value when I use the same key in the following Haskell code (whether that be on Windows 10 or Ubuntu 18.04.3 LTS):
{-# LANGUAGE OverloadedStrings #-}
import Data.OTP
import Data.Time.Clock
main = do
-- This key is just for testing purposes
let theSecretKey = "abcdefghijklmnop"
-- See http://hackage.haskell.org/package/OTP-0.1.0.0/docs/Data-OTP.html#g:2
curTime <- getCurrentTime
let theTOTP = totp SHA1 theSecretKey curTime 30 6
print theTOTP
I reckon this means the above code has a bug. If I were to hazard a guess, either "theSecretKey" or "curTime" is being passed in an invalid format, but I'm not sure which.
What should I change in the above code to correctly call the totp function?
NOTE: While testing with oathtool, I was able to verify that I should be using the SHA1 hashing algorithm