2
Hello!
I’m looking for a way to mask emails in the database, but in a way that I can reverse them without much difficulty, in case I need the real email.
My idea is to create a Rigger AFTER INSERT
for this. Will not be used in production environment.
My idea was to get emails like:
[email protected]
[email protected]
[email protected]
Turn:
[email protected]
[email protected]
[email protected]
That is, I would like to change the characters after the last point (.) of the email to a random varchar. The size of the replaced text does not need to be the same as the original text.
Does anyone know a quiet way to do this? I don’t know how to take the position of the last point, this seems to be crucial to doing what I want. I wouldn’t want to create a function
for this.
I can even mess up the e-mail before the @
with:
UPDATE pessoa
SET email=STUFF(email, 1, CHARINDEX('@', email)-1, LEFT(REPLACE(CAST(NEWID() AS VARCHAR(36)), '-', ''), 4+ABS(CHECKSUM(NEWID()))%4))
Resulting in:
[email protected]
But it’s not what I want right now.
It worked perfectly! I ended up getting another way here too, I will also post as answer.
– Dherik
I think we think similar ;P. Aaah your way got cleaner and with less function ;)
– Barbetta
my solution has 3 Reverse, it was not as good as rs.
– Dherik