Find Us

Address
123 Main Street
New York, NY 10001

Hours
Monday—Friday: 9:00AM–5:00PM
Saturday & Sunday: 11:00AM–3:00PM

Categories

Using the SameText method with TypingDNA Authentication API

What is the SameText method and how to use it?

At TypingDNA, we have two main ways of comparing typing patterns: SameText and AnyText. These options exist because TypingDNA technology is used in different situations.

SameText requires that each new typing pattern is collected on exactly the same text as the previously saved patterns. This might seem limiting, but it enables the highest possible accuracy. Recently this method received a breakthrough accuracy improvement, that makes TypingDNA comparable to fingerprint and face recognition, read more.

AnyText is an older method that we do not recommend except for very few use cases, as it is less accurate and requires a lot of text (the user has to type at least 140 characters). Its benefit is that it does not require the same text—users can type anything, and the typing pattern can still be compared to earlier patterns of similar size (but different content).

In this explanation, we will only focus on SameText.

The SameText method considers how a person types a short phrase (for example, a 4-word combination or a brief sentence). One such example is: “anything mosquito rainbow angel”

During both enrollment and verification, the user must type exactly that phrase. One or two typos can be allowed, but only if you know precisely what text is required (Case 1 bellow).

Required settings for SameText to work

Type 2 is recommended.

The SameText method works with type:1 and type:2 patterns, but we strongly recommend using type:2. Type:2 is a linear typing pattern, including each character’s timing in the order it was typed. If mistakes occur and are corrected before submission, the TypingDNA recorder can omit them if the text parameter is set correctly.

The text param is mandatory.

For SameText to work, the typing pattern must be gathered on the exact text. This text may be known beforehand or may be determined by the user’s input.

Case 1: the text to be typed is known (e.g. “anything mosquito rainbow angel”)

For example, if the required text is “anything mosquito rainbow angel,” then after the user types it, you call:

var typingPattern = tdna.getTypingPattern({ type: 2, text: "anything mosquito rainbow angel" });

Case 2: the text is not known (e.g. “username password email”)

For instance, the user types something into an input text field called textInput. You still need the SameText method to capture exactly what the user typed, but omit any potential mistakes the user typed and deleted after, so you call:

var typingPattern = tdna.getTypingPattern({ type: 2, text: textInput.value });

Even if the user made mistakes and corrected them, the final textInput.value will match their submitted text. The TypingDNA recorder then extracts the correct keystroke data from its internal log.

What if the text param value is different or omitted?

If the text parameter changes between calls, the text ID also changes. Because we use an FNV hash to create a unique text ID for each text, any new text is treated as a separate pattern. Depending on your settings, this could be enrolled as a new pattern (if /auto endpoint is used) or compared using the AnyText method, which is less accurate for short texts.

If the text parameter is omitted entirely, the authentication will default to the AnyText method—again less accurate for short texts.

Bottom line: Always use the same text parameter value for SameText.

Auto-enroll and the /auto API endpoint

The Auto-enroll setting (used with the /auto endpoint) is simple to use and lets you manage enrollment and verification directly from the developer administration area.

Traditionally, you would:

  1. Record and enroll a typing pattern for a new user and new text ID (using /save).
  2. Repeat this 2–3 times.
  3. Start verification (using /verify).
  4. After a successful verification, decide whether to also enroll that new typing pattern (another /save).

This means extra API calls and server-side logic.

With /auto, our server automatically decides when to enroll, when to verify, and when to do both. You can set a minimal threshold for enrollment and a required number of initial enrollments before verification begins—directly in the admin area.

Unless you need custom logic that differs from the standard, we recommend using Auto-enroll (set to “on”) and using the /auto endpoint instead of /save or /verify. You can learn more about /auto in the TypingDNA API documentation.

Share: