Your IP: Unknown · Your Status: ProtectedUnprotectedUnknown

Skip to main content

What is a one-time password (OTP)? A detailed guide with examples

One-time passwords (OTPs) are a widely used user authentication method adopted by companies worldwide. OTPs help protect accounts from unauthorized access by requesting an auto-generated temporary password that only the account holder should know. How do they work — and are they secure? Here’s our complete guide to OTPs with examples.

What is a one-time password (OTP)? A detailed guide with examples

Table of Contents

Table of Contents

What is a one-time password?

A one-time password is an auto-generated authorization code that authenticates a user when they log in to an account, network, or system.

Unlike traditional passwords, one-time passwords are only valid once and for a set period. While you may use the same password to log in time after time until you reset it, one-time passwords are always unique and change with every login.

One-time passwords are a common method of two-factor authentication (2FA) — a password security practice that requires two forms of identification to gain access to an account or network.

One-time passwords (also known as one-time passcodes) are typically numeric or alphanumeric. They are widely used as a two-factor authentication method by companies across all industries.

One-time password vs. static password

Let’s clarify the key differences between a one-time password and a static password.

A static password is a traditional, user-created password that typically expires every 30 to 60 days. A user can create this password manually or use a password generation tool. Once they’ve created a password, it will remain static until the user has intentionally changed or reset it.

In contrast, a one-time password is only valid once and for a short time when a user completes a single login session. OTPs are also known as dynamic or single-use passwords because they change with each login session, and users can only enter them once.

How do one-time passwords work?

The idea behind a one-time password is straightforward. Authentication using two or more methods uses two of the following three factors:

  • Something you know (i.e., your static password)
  • Something you have (e.g., a token, a cryptographic identification device, a passcode)
  • Something you are (i.e., biometric data like your fingerprint or face ID)

While a static password is something you have created and know, a one-time password is something you have. Here’s how most one-time passwords work:

  • When users attempt to log in to their account or an application, the platform asks them to confirm their identity by entering a string of numeric or alphanumeric characters.
  • These characters are generated automatically using the Hashed Message Authentication Code (HMAC) and a moving factor. The two main moving factors of OTPs are time based (TOTP) and event based (HOTP). We’ll cover these in more detail in a section below.
  • This one-time password is delivered to the user via a channel only the user should have access to: by email, an authenticator app, a security key device, a text message, or a push notification.
  • The user then enters the one-time password in the required field to verify their identity or authenticate an action.

You can generate a one-time password in several ways, which we’ll cover in the examples below.

Types of one-time passwords

There are two main types of OTPs: HOTPs and TOTPs. Let’s review each type in more detail.


HOTP is an event-based one-time password. The “H” stands for Hash-based Message Authentication Code (or HMAC) — a specific message authentication code that involves a cryptographic hash function and a secret cryptographic key.

When a user requests a HOTP, the generated code is valid until they request a new one. That’s because the generation of HOTP is based on a counter. The server and the OTP generator are synchronized each time the code is validated, and the user enters the account.

A good example of an OTP generator that uses HOTP is Yubico’s YubiKey — a small security key that you can use to protect multiple accounts.


While HOTP is event based, TOTP is time based. TOTP stands for “time-based one-time password.” TOTP uses the same algorithm as HOTP but replaces the event counter with a time counter.

When a user requests a TOTP, the generated code is only valid for a short time — typically between 30 and 90 seconds. After that, the code expires and cannot be used again.

TOTPs are generally more secure than HOTPs because they expire more frequently.

One-time password examples

OTP systems are commonly used by companies across various industries, from financial institutions to schools.

Whether you’re accessing your bank account or making changes to an online hotel reservation, you will likely be asked to enter a numeric code to confirm your identity. Here are some examples of one-time passwords.

Email or text authentication

The simplest and most accessible method of OTP authentication is receiving an email or a text message with a one-time password.

Many companies employ two-factor authentication methods to confirm transactions or make changes to bookings.

Authentication devices

Authenticator devices (also known as security keys) are security hardware devices that produce single-use passwords. These devices include pocket-size key fobs (e.g., YubiKey) that generate a numeric or alphanumeric one-time code.

Smart cards

Smart cards (also known as OTP display cards) are microprocessor-based cards resembling credit or debit cards. They have an LCD screen that shows the generated numeric or alphanumeric one-time code.

Examples of smart cards include the SafeNet OTP Display Card and Feitian OTP display card.

Mobile device apps

You can also download an authenticator app for generating one-time passcodes. These mobile apps work similarly to security tokens — but the code is generated in-app. Users can copy the code to verify their identity when logging in to a website or service.

Some well-known authenticator apps include Google Authenticator, Authy, and Microsoft Authenticator.

What are the advantages and disadvantages of one-time passwords?

OTPs have many advantages and benefits. However, they also have some disadvantages to keep in mind. Let’s look at the pros and cons in more detail.


  • Improved digital security. Using OTPs as a second authentication factor significantly increases your cybersecurity. Multi-factor authentication reduces the risk of unauthorized access and cyberattacks, which are a constant threat.
  • Prevent replay attacks. Replay attacks involve criminals intercepting a user’s internet traffic and later using it to gain access to online profiles. OTPs help prevent replay attacks, especially in banking transactions. Since an OTP is only valid for a short time or one transaction, it won’t work if an attacker tries to replay it.
  • No need to remember OTPs. Having to reset forgotten passwords is no fun. Since OTPs are auto-generated, users don’t have to worry about remembering another password.
  • Quick and easy to use. The authentication process using a one-time password is typically fast and easy. All you have to do is enter the code you received through an indicated channel, and you can access your account.


  • Security issues. While a one-time password provides more security than a traditional password, it isn’t completely attack-proof. Hackers can circumvent OTP security systems in several creative ways, like phishing or social engineering attacks.
  • Access issues and delays. Not all OTP systems are as effective as they should be. Sometimes, users may experience a delay in getting an email with their one-time password — or it may end up in the spam folder.
  • Authentication requires extra effort. OTP authentication isn’t as simple as entering your username and password. Users need to complete additional steps to authenticate their actions, which requires a little more effort and time.
  • The process can be inconvenient. In many cases, a user needs to have their mobile phone at hand when using OTP authentication (e.g., using a mobile application to generate a one-time password or receiving codes via text messages). While most of us carry our phones at all times, relying on mobile devices could be inconvenient for some people.

Are one-time passwords secure?

A one-time password is considered a secure identity verification method and is widely used by companies worldwide.

Providing secure access to applications is a constant challenge for businesses across all industries. Security measures like OTPs are a simple, effective, and reliable way to protect user information and sensitive data.

Using a one-time password adds a layer of security to the login process and provides secure access to an account or application. OTPs are more secure than static passwords (especially if these are short or reused elsewhere).

However, like most login methods, OTP systems are only partially hack-proof. Hackers can still find ways to use OTPs to get into accounts — but it isn’t an easy attack to execute.

OTPs are vulnerable to certain types of scams, like social engineering and phishing attacks, email hijacking, or SMS code theft. It is important to remain cautious and not fall for common hacker tricks.

Ultimately, OTPs are a proven and reliable authentication method that reduces the likelihood of fraud, compromised accounts, and other cyberattacks. Using a one-time password in addition to your traditional password adds an extra layer of security and gives you more peace of mind.

Increase your password security

While one-time passwords help protect your accounts with an additional step of authentication, your traditional passwords safe is just as important.

Remember to create long, strong passwords to make them challenging for hackers to guess — and never reuse previous passwords.

For more information, check out these tips for creating a secure password and consider using a password manager to take your account security further.