# Replace the first n characters

This function masks the first n characters, while the following ones remain as is.

| Option | Description |
| --- | --- |
| Method | The Randomly method randomly<br>selects a character. As a result, two identical input values can be masked with<br>different output values.<br><br>When the same value appears twice in<br>the input data, the Consistently<br>method ensures that the function outputs the same masked value in the same<br>Job execution.<br><br>This function can encrypt the output masked<br>values in the same format as the input values, using Format-Preserving Encryption (FPE)<br>methods:<br><br><ul> <li> <span>FF1 with AES</span> relies on the                Advanced Encryption Standard in CBC mode.</li> <li> <span>FF1 with SHA-2</span> relies on the                secure hash function HMAC-256.</li> </ul><br><br>The FPE methods are bijective methods, except when<br>using tweaks.<br><br>The FF1 with<br>AES and FF1 with SHA-2 methods<br>require a password to generate encrypted and repeatable masked values. Those FPE methods<br>do not use a seed.<br><br>You can specify this password in the<br>password for FF1 method field, from the<br>Advanced Settings of the component. |
| Extra parameter | This function requires an extra parameter.<br><br>The extra parameter must be a number.<br>This is the number of characters to be masked.<br><br>You<br>can enter a second extra parameter, which is the replacement<br>character. |

In the following examples, the first two characters from the input values are masked.

In the first example, the replacement character is not defined. The first two characters are masked with random characters.

In the second example, the first two characters are masked with the defined character.

| Input value | Method | Extra parameter | Example of a masked value |
| --- | --- | --- | --- |
| Jack | Randomly | "2" | Pvck |
| S1000D | Randomly | "2,s" | ss000D |