From: Rob Sargent <robjsargent@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Replace anonymized data in string
Date: Fri, 12 Nov 2021 08:07:03 -0700
Message-ID: <252c3b66-cfa1-d305-0341-c5a4b590f476@gmail.com> (raw)
In-Reply-To: <VI1PR05MB5917D508CAA017AB9FF70890EF959@VI1PR05MB5917.eurprd05.prod.outlook.com>
References: <VI1PR05MB5917D508CAA017AB9FF70890EF959@VI1PR05MB5917.eurprd05.prod.outlook.com>
On 11/12/21 7:12 AM, Patrick FICHE wrote:
>
> Hi Team,
>
> I have some data that has been anonymized and I would like to generate
> some test data from this. In some way, I would like to deanonymize
> this data with random data.
>
> For example, phone numbers have been anonymized with changing the 5
> right digits with the 8 digit (preserving length).
>
> Applying this, the number 390694802756 was changed to 3906948088888.
>
> I would like to get random digits at the end of the phone number
> knowing that anonymized data can be a variable length.
>
> So, I would like to change every sequence (at least 2) of 8 by random
> value of same length (I don’t worry if phone number contains 88 in the
> middle and this sequence is changed to random data)…
>
> I tried to do this with replace / regexp_replace functions but could
> not achieve what I wanted to do.
>
> I don’t want these digits to be changed with a single one (88888 by
> 111111 or 99999 but something like 42384)…
>
> Ideally, the new string would be different if multiple sequences of 8
> appear in a string and would be different from one record to the other
> when applied to a full table…
>
> Is there any way to do this ?
>
> Thanks,
>
> Patrick
>
Usual trick it to select floor(random()*100000);
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: robjsargent@gmail.com
Subject: Re: Replace anonymized data in string
In-Reply-To: <252c3b66-cfa1-d305-0341-c5a4b590f476@gmail.com>
References: <VI1PR05MB5917D508CAA017AB9FF70890EF959@VI1PR05MB5917.eurprd05.prod.outlook.com> <252c3b66-cfa1-d305-0341-c5a4b590f476@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox