Need to Mask Data


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to Mask Data
# 1  
Old 08-11-2010
MySQL Need to Mask Data

I have an requirement. There is a file which has the below contents

Unix|123|17-01-2010
....
....
....
....
and so an

now each letter has a corresponding predefined mapping letter in order to mask the original data.(for example U = A,
n=b, i=c, x=d, same like number 1=9,2=8,3=7. Also for date field it will have default date as 01-01-1999).

Like wise i will have so many rows in the file. How to mask the data

The idea is to mask the original contents. Every upper case A to Z and a to z will have corresponding letter to map,
same like 0 to 9 will have corresponding number

After masking the data the original file content will replace with the masked data.

Any idea how to go about this requirement

Thanks
Babu
# 2  
Old 08-11-2010
I already have a script which does a similar function, but with a small difference. Rather than map each letter/number to a different letter/number, it cycles though the alphabet/digits.
Code:
$ echo 'Unix|300|17-01-2010' | awk '
{
    for(i=1;i<=length;i++){
         c=substr($0,i,1)
         d=substr($0,i,10)
         if(d~/^[0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]$/) {
            printf "01-01-1999"
            i+=9
         }
         else
         if(c~/[0-9]/) {
            pn++
            if(pn>10) pn=1
            printf substr("1234567890", pn, 1)
         }
         else if(c~/[A-Z]/) {
            pl++
            if(pl>26) pl=1
            printf substr("ABCDEFGHIJKLMNOPQRSTUVWXYZ", pl, 1)
         }
         else if(c~/[a-z]/) {
            pl++
            if(pl>26) pl=1
            printf substr("abcdefghijklmnopqrstuvwxyz", pl, 1)
         }
         else
            printf c
    }
    printf ORS
}'
Abcd|123|01-01-1999

# 3  
Old 08-12-2010
Thanks Yogor

---------- Post updated 08-12-10 at 09:55 AM ---------- Previous update was 08-11-10 at 01:03 PM ----------

Anybody has some idea which perfectly suits my need
# 4  
Old 08-12-2010
You can probably create a map file with contents something like this....

Code:
abcdefghijklmnopqrstuvwxyz1234567890
374df2dmd94nflt934272840ndn2834m4827

And you need to run a translate using the map file..

Code:
cat infile | tr "[`sed -n 1p map`]" "[`sed -n 2p map`]"   > outfile

I am not sure if that would satisfy your requirements entirely.
# 5  
Old 08-13-2010
Hi Rajamadhavan

This is not my requirement .. anyway thanks. But if you have any idea which suits my need would be great help.

My Need is every upper case and lower case letter (A-Z, a-z) has predefined mask letter (ex. A=Y... a=y and for numbers 1=0)

Then the file input is

Apple|123|13-08-2010
.....
.....
....
and so on

Babu
# 6  
Old 08-13-2010
Hi Babu,
The solution I provided was to create a file to define the letters in one line and the corresponding mask letter the second line. Then use this map file to encrypt the input file.


In your setup, where from you fetch the mask letters ?



-Raja
# 7  
Old 08-16-2010
Hi Raja

I fetch mask letter from another files.

Babu
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

What is mask and effective right mask in setfacl?

Hi Guys, can someone explain what is mask and effective right mask in setfacl and getfacl command with example, unable to get it. (3 Replies)
Discussion started by: Jcpratap
3 Replies

2. Shell Programming and Scripting

Mask the Oracle Database Data

Hi, We have to mask the data that is coming from production environment to Non-production environment. The database is running in oracle platform. If anybody has generic scripts to achive this task,it would be great if that can be shared with me? Thank you, Jayaprakash. (10 Replies)
Discussion started by: bandaru_0810
10 Replies

3. Red Hat

Samba create mask and dir mask on RHEL 4.8

Hi Experts, I'm using samba -3.6.1 on Red Hat Enterprise Linux ES release 4 (Nahant Update 8) ,all seems ok. The issue im facing is as follows. When ever a user creates a file via windows explorer the permissions assgined to the file are as follows -rw-rwxr--+ 1 tom group2 0 Mar 9... (1 Reply)
Discussion started by: maverick_here
1 Replies

4. UNIX for Dummies Questions & Answers

How do mask off the string that match my value?

Hi, I have a file like following, aaabb aaavv bbdddaaab fgdgjhaa bfd 12352aa dgs1xaf sdgsdyg4 How can i get the output below(mask off all the line that have "a") by using vim #aaabb #aaavv #bbdddaaab #fgdgjhaa bfd #12352aa (4 Replies)
Discussion started by: 793589
4 Replies

5. UNIX for Dummies Questions & Answers

how to mask the password ?

Hi All, i am executing peoplesoft sqr command from unix prompt which has the unix id/password as parameter along with other parameters. i want to show whole command in log file but want to mask the id/password field. this command i am executing in shell script. Please suggest.. >sqr sqrname... (2 Replies)
Discussion started by: avi.coep
2 Replies

6. Shell Programming and Scripting

mask ID number

HP-UX 11i v2. #!/bin/sh Hi all. I have a flat file like this with lines like this: |07/19/07|08:26AM|1|CupsCoffee|CupsCo|989898989 |Doe, John Y |THE PLUS CARD - Price| | |Y| | 2.00| I would like to replace the id number (field 6) with a masked... (3 Replies)
Discussion started by: lyoncc
3 Replies

7. UNIX for Dummies Questions & Answers

overriding the mask in setfacl

hello everbody: Im trying to give the user "ydarwish" a full access over some directory on my sol9 machine. however the setfacl is recalculating the mask parameter keeping me from keeping him effective write and read access: root@Obi-Wan> setfacl -m u:ydarwish:rwx /IN_ARCHIVE6 root@Obi-Wan>... (4 Replies)
Discussion started by: aladdin
4 Replies

8. IP Networking

Changing the mask

What is the command to change the mask to 255.255.255.0 The system was set up incorectly and the mask needs to be corrected (1 Reply)
Discussion started by: kkinnon
1 Replies

9. Programming

password mask in C

Hi, Could any one help me to write a C program for password mask with ******. I mean whatever word i will type that will show on the screen as ***** and should store the correct value in a variable. Thanks in advance Krishna (5 Replies)
Discussion started by: krishna
5 Replies

10. IP Networking

Subnet mask

Hi, I have about 30 computers for users with subnet mask x.x.x.0, and 25 computers for workers with s.m. x.x.x.128. My server has a s.m. x.x.x.128 so with workers computers I can see my server and all the computers in that s.m., but I can't see the server from the users computers and I need to see... (7 Replies)
Discussion started by: Z0DiaC
7 Replies
Login or Register to Ask a Question