/// <summary> /// Generates the time-based password (RFC 6238) /// </summary> /// <param name="secret">The secret key to generate password</param> /// <param name="interval">The interval length (seconds) to generate password - Authenticator app (just like Google /Microsoft) uses 30 seconds interval length</param> /// <param name="digits">The number of password digits</param> /// <returns></returns> public static string GeneratePassword(byte[] secret, int interval = 30, int digits = 6) => OTPService.GeneratePassword(secret, DateTime.Now.ToUnixTimestamp() / (interval > 0 ? interval : 30), digits);
/// <summary> /// Generates the time-based password (RFC 6238) /// </summary> /// <param name="secret">The secret key to generate password</param> /// <param name="interval">The interval length (seconds) to generate password - Authenticator app (just like Google /Microsoft) uses 30 seconds interval length</param> /// <param name="digits">The number of password digits</param> /// <returns></returns> public static string GeneratePassword(string secret, int interval = 30, int digits = 6) => OTPService.GeneratePassword(secret.ToBytes(), interval, digits);
/// <summary> /// Generates the counter-based password (RFC 4226) /// </summary> /// <param name="secret">The secret key to generate password</param> /// <param name="counter">The counter to generate password from the secret key</param> /// <param name="digits">The number of password digits</param> /// <returns></returns> public static string GeneratePassword(string secret, long counter, int digits = 6) => OTPService.GeneratePassword(secret.ToBytes(), counter, digits);