Anonymize identification number

Hello

I am building a library that should be able to anonymize identification numer in this format:

  • 112233-4455
  • 1122334455

I would like to be able to anonymise either from the left or right, base on an in-argument for “number of characters to anonymize” is positive or negative Eg.:

  • 6’ should replace the first 6 characters with XXXXXX
  • -4’ should replace the last 4 characters with XXXX

How is this done in the smartest way?

one of many options:

using regex
select the pattern depending to the input argument

  • e.g. with the help of a switch activity

using Regex.Replace

e.g.:

And

@SorenB,

Try these steps:

  1. Assign lengthToAnonymize = Math.Abs(numCharactersToAnonymize)

  2. If numCharactersToAnonymize >= 0
    Then:

    • Assign prefix = New String("X"c, lengthToAnonymize)
    • Assign suffix = inputNumber.Substring(lengthToAnonymize)
    • Assign anonymizedNumber = prefix + suffix
      Else:
    • Assign prefix = inputNumber.Substring(0, inputNumber.Length - lengthToAnonymize)
    • Assign suffix = New String("X"c, lengthToAnonymize)
    • Assign anonymizedNumber = prefix + suffix
  3. Return anonymizedNumber

Thanks,
Ashok :slight_smile:

Hi @SorenB

I think below zip file should help you it’s an library project.

Anonymization Library.zip (141.1 KB)

Arguments:

Variables:

Hope it helps!!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.