New Translate Function
Given the recent article and How Do I request on how to Obfuscate test data I realized that if I wrote a new function to do this transformation of a byte field if there was a method to provide a from character and a to character. So we've added the Translate command to specify what character to translate from and to, and the $translate function to apply that translation table. The translate command allows you to specify in decimal the character you want to translate from and to. For example if you want to transform Capital-A to Capital-Z you just enter the commandTranslate "^65:^90" ext name=$translate(name)The extract command will change "Neil Armstrong" to "Neil Zrmstrong". We've also provided a sample translation table which will translate many readable characters to other readable characters just by using:
Translate TounreadYou can see an example below:
>get m-supplier >ext supplier-name >list stan >xeq May 02, 2014 8:08 Base STORE.TESTSD Set M-SUPPLIER Page 1 SUPPLIER-NAME Makita Canada Inc SKIL Power Tools Black & Decker IN=3, OUT=3. CPU-Sec=1. Wall-Sec=1. >get m-supplier >translate tounread >update >ext supplier-name=$translate(supplier-name) >xeq Update all records from the M-SUPPLIER dataset [no]: yes Warning: Using DBGET for the input records IN=3, OUT=3. CPU-Sec=1. Wall-Sec=1. >get m-supplier >ext supplier-name >list stan >xeq May 02, 2014 8:12 Base STORE.TESTSD Set M-SUPPLIER Page 1 SUPPLIER-NAME Npzxep Qpmpsp Wmr HYWZ Klhtc Gllod Poprz ; Rtrztc IN=3, OUT=3. CPU-Sec=1. Wall-Sec=1. >get m-supplier >translate toread >ext supplier-name=$translate(supplier-name) >list >list stan Warning: Previous >LIST options reset >xeq May 02, 2014 8:12 Base STORE.TESTSD Set M-SUPPLIER Page 1 SUPPLIER-NAME Makita Canada Inc SKIL Power Tools Black & Decker IN=3, OUT=3. CPU-Sec=1. Wall-Sec=1.This new feature is not meant as a method to encrypt data but does allow for you to quickly make test data unreadable.
Obfuscating Test Data
I recently was asked how could you Obfuscate data in a byte type field AND be able to bring it back. Short of writing a $encrypt and $decrypt function, which may be in the works, I came up with the following:
Note the Product-desc field:/RUN SUPRTOOL.PUB.ROBELLE SUPRTOOL/Copyright Robelle Solutions Technology Inc. 1981-2014. (Version 5.6.12 Internal) MON, APR 7, 2014, 3:46 PM Type H for help. >BASE STORE,5,READER >GET M-PRODUCT >LIST >XEQ >GET M-PRODUCT (4) >OUT $NULL (0) PRODUCT-DESC = Skil 3/8" Variable Speed Drill PRODUCT-MODEL = #6523 PRODUCT-NO = 50531501 >GET M-PRODUCT (39) >OUT $NULL (1) PRODUCT-DESC = B&D Router PRODUCT-MODEL = #7613-04 PRODUCT-NO = 50522001 >GET M-PRODUCT (49) >OUT $NULL (2) PRODUCT-DESC = Skil Var. Sp. Auto-Scroll Saw PRODUCT-MODEL = #4560 PRODUCT-NO = 50533001 >GET M-PRODUCT (50) >OUT $NULL (3) PRODUCT-DESC = Skil 8 1/2" Circular Saw PRODUCT-MODEL = #5665 PRODUCT-NO = 50532501 >GET M-PRODUCT (52) >OUT $NULL (4) PRODUCT-DESC = B&D Cordless Screwdriver PRODUCT-MODEL = #9018-04 PRODUCT-NO = 50521001 >GET M-PRODUCT (103) >OUT $NULL (5) PRODUCT-DESC = Makita 8 1/4" Circular Saw PRODUCT-MODEL = #5008NB PRODUCT-NO = 50512501 >GET M-PRODUCT (146) >OUT $NULL (6) PRODUCT-DESC = B&D Variable Speed Jig Saw PRODUCT-MODEL = #7548-04 PRODUCT-NO = 50523001 >GET M-PRODUCT (164) >OUT $NULL (7) PRODUCT-DESC = Makita 1/2" Router PRODUCT-MODEL = #3601B PRODUCT-NO = 50512001 >GET M-PRODUCT (171) >OUT $NULL (8) PRODUCT-DESC = Makita 3/8" Var. Speed Drill PRODUCT-MODEL = #DP3730 PRODUCT-NO = 50511501 >GET M-PRODUCT (221) >OUT $NULL (9) PRODUCT-DESC = Skil Router PRODUCT-MODEL = #1835 PRODUCT-NO = 50532001 >GET M-PRODUCT (231) >OUT $NULL (10) PRODUCT-DESC = B&D 7 1/4" Circular Saw PRODUCT-MODEL = #5728 PRODUCT-NO = 50522501 >GET M-PRODUCT (241) >OUT $NULL (11) PRODUCT-DESC = B&D 3/8" Variable Speed Drill PRODUCT-MODEL = #P1149 PRODUCT-NO = 50521501 >GET M-PRODUCT (243) >OUT $NULL (12) PRODUCT-DESC = Makita 1" Jig Saw PRODUCT-MODEL = #4300 BV PRODUCT-NO = 50513001 IN=13, OUT=13. CPU-Sec=1. Wall-Sec=1.I made a simple translate file with the intended use being in a table with data. The key would be match to the original data and the Trans field would be what the data would become.
>in trans1 >list >xeq >IN TRANS1.NEIL.GREEN (0) >OUT $NULL (0) KEY = A TRANS = S >IN TRANS1.NEIL.GREEN (1) >OUT $NULL (1) KEY = B TRANS = T >IN TRANS1.NEIL.GREEN (2) >OUT $NULL (2) KEY = C TRANS = U >IN TRANS1.NEIL.GREEN (3) >OUT $NULL (3) KEY = D TRANS = V >IN TRANS1.NEIL.GREEN (4) >OUT $NULL (4) KEY = E TRANS = W >IN TRANS1.NEIL.GREEN (5) >OUT $NULL (5) KEY = F TRANS = X >IN TRANS1.NEIL.GREEN (6) >OUT $NULL (6) KEY = G TRANS = Y >IN TRANS1.NEIL.GREEN (7) >OUT $NULL (7) KEY = H TRANS = Z >IN TRANS1.NEIL.GREEN (8) >OUT $NULL (8) KEY = I TRANS = A >IN TRANS1.NEIL.GREEN (9) >OUT $NULL (9) KEY = J TRANS = B >IN TRANS1.NEIL.GREEN (10) >OUT $NULL (10) KEY = K TRANS = C >IN TRANS1.NEIL.GREEN (11) >OUT $NULL (11) KEY = L TRANS = D >IN TRANS1.NEIL.GREEN (12) >OUT $NULL (12) KEY = M TRANS = E >IN TRANS1.NEIL.GREEN (13) >OUT $NULL (13) KEY = N TRANS = F >IN TRANS1.NEIL.GREEN (14) >OUT $NULL (14) KEY = O TRANS = G >IN TRANS1.NEIL.GREEN (15) >OUT $NULL (15) KEY = P TRANS = H >IN TRANS1.NEIL.GREEN (16) >OUT $NULL (16) KEY = Q TRANS = I >IN TRANS1.NEIL.GREEN (17) >OUT $NULL (17) KEY = R TRANS = J >IN TRANS1.NEIL.GREEN (18) >OUT $NULL (18) KEY = S TRANS = K >IN TRANS1.NEIL.GREEN (19) >OUT $NULL (19) KEY = T TRANS = L >IN TRANS1.NEIL.GREEN (20) >OUT $NULL (20) KEY = U TRANS = M >IN TRANS1.NEIL.GREEN (21) >OUT $NULL (21) KEY = V TRANS = N >IN TRANS1.NEIL.GREEN (22) >OUT $NULL (22) KEY = W TRANS = O >IN TRANS1.NEIL.GREEN (23) >OUT $NULL (23) KEY = X TRANS = P >IN TRANS1.NEIL.GREEN (24) >OUT $NULL (24) KEY = Y TRANS = Q >IN TRANS1.NEIL.GREEN (25) >OUT $NULL (25) KEY = Z TRANS = R >IN TRANS1.NEIL.GREEN (26) >OUT $NULL (26) KEY = a TRANS = s >IN TRANS1.NEIL.GREEN (27) >OUT $NULL (27) KEY = b TRANS = t >IN TRANS1.NEIL.GREEN (28) >OUT $NULL (28) KEY = c TRANS = u >IN TRANS1.NEIL.GREEN (29) >OUT $NULL (29) KEY = d TRANS = v >IN TRANS1.NEIL.GREEN (30) >OUT $NULL (30) KEY = e TRANS = w >IN TRANS1.NEIL.GREEN (31) >OUT $NULL (31) KEY = f TRANS = x >IN TRANS1.NEIL.GREEN (32) >OUT $NULL (32) KEY = g TRANS = y >IN TRANS1.NEIL.GREEN (33) >OUT $NULL (33) KEY = h TRANS = z >IN TRANS1.NEIL.GREEN (34) >OUT $NULL (34) KEY = i TRANS = b >IN TRANS1.NEIL.GREEN (35) >OUT $NULL (35) KEY = j TRANS = c >IN TRANS1.NEIL.GREEN (36) >OUT $NULL (36) KEY = k TRANS = d >IN TRANS1.NEIL.GREEN (37) >OUT $NULL (37) KEY = l TRANS = e >IN TRANS1.NEIL.GREEN (38) >OUT $NULL (38) KEY = m TRANS = f >IN TRANS1.NEIL.GREEN (39) >OUT $NULL (39) KEY = n TRANS = g >IN TRANS1.NEIL.GREEN (40) >OUT $NULL (40) KEY = o TRANS = h >IN TRANS1.NEIL.GREEN (41) >OUT $NULL (41) KEY = p TRANS = i >IN TRANS1.NEIL.GREEN (42) >OUT $NULL (42) KEY = q TRANS = j >IN TRANS1.NEIL.GREEN (43) >OUT $NULL (43) KEY = r TRANS = k >IN TRANS1.NEIL.GREEN (44) >OUT $NULL (44) KEY = s TRANS = l >IN TRANS1.NEIL.GREEN (45) >OUT $NULL (45) KEY = t TRANS = m >IN TRANS1.NEIL.GREEN (46) >OUT $NULL (46) KEY = u TRANS = n >IN TRANS1.NEIL.GREEN (47) >OUT $NULL (47) KEY = v TRANS = o >IN TRANS1.NEIL.GREEN (48) >OUT $NULL (48) KEY = w TRANS = a >IN TRANS1.NEIL.GREEN (49) >OUT $NULL (49) KEY = x TRANS = p >IN TRANS1.NEIL.GREEN (50) >OUT $NULL (50) KEY = y TRANS = q >IN TRANS1.NEIL.GREEN (51) >OUT $NULL (51) KEY = z TRANS = r >IN TRANS1.NEIL.GREEN (52) >OUT $NULL (52) KEY = 1 TRANS = 9 >IN TRANS1.NEIL.GREEN (53) >OUT $NULL (53) KEY = 2 TRANS = 8 >IN TRANS1.NEIL.GREEN (54) >OUT $NULL (54) KEY = 3 TRANS = 7 >IN TRANS1.NEIL.GREEN (55) >OUT $NULL (55) KEY = 4 TRANS = 6 >IN TRANS1.NEIL.GREEN (56) >OUT $NULL (56) KEY = 5 TRANS = 5 >IN TRANS1.NEIL.GREEN (57) >OUT $NULL (57) KEY = 6 TRANS = 4 >IN TRANS1.NEIL.GREEN (58) >OUT $NULL (58) KEY = 7 TRANS = 3 >IN TRANS1.NEIL.GREEN (59) >OUT $NULL (59) KEY = 8 TRANS = 2 >IN TRANS1.NEIL.GREEN (60) >OUT $NULL (60) KEY = 9 TRANS = 1 >IN TRANS1.NEIL.GREEN (61) >OUT $NULL (61) KEY = / TRANS = * >IN TRANS1.NEIL.GREEN (62) >OUT $NULL (62) KEY = & TRANS = ! >IN TRANS1.NEIL.GREEN (63) >OUT $NULL (63) KEY = . TRANS = ) >IN TRANS1.NEIL.GREEN (64) >OUT $NULL (64) KEY = " TRANS = : >IN TRANS1.NEIL.GREEN (65) >OUT $NULL (65) KEY = _ TRANS = | >IN TRANS1.NEIL.GREEN (66) >OUT $NULL (66) KEY = - TRANS = } IN=67, OUT=67. CPU-Sec=1. Wall-Sec=1. rename trans1,translteI use this file in a table to do the translation:
>BASE STORE,1,WRITER >get m-product >TABLE MYTRANS,KEY,FILE,TRANSLTE,DATA(TRANS),HOLD There are 67 entries in MYTRANS >DEF A,PRODUCT-DESC[1],1,BYTE >DEF B,PRODUCT-DESC[2],1,BYTE >DEF C,PRODUCT-DESC[3],1,BYTE >DEF D,PRODUCT-DESC[4],1,BYTE >DEF E,PRODUCT-DESC[5],1,BYTE >DEF F,PRODUCT-DESC[6],1,BYTE >DEF G,PRODUCT-DESC[7],1,BYTE >DEF H,PRODUCT-DESC[8],1,BYTE >DEF I,PRODUCT-DESC[9],1,BYTE >DEF J,PRODUCT-DESC[10],1,BYTE >DEF K,PRODUCT-DESC[11],1,BYTE >DEF L,PRODUCT-DESC[12],1,BYTE >DEF M,PRODUCT-DESC[13],1,BYTE >DEF N,PRODUCT-DESC[14],1,BYTE >DEF O,PRODUCT-DESC[15],1,BYTE >DEF P,PRODUCT-DESC[16],1,BYTE >DEF Q,PRODUCT-DESC[17],1,BYTE >DEF R,PRODUCT-DESC[18],1,BYTE >DEF S,PRODUCT-DESC[19],1,BYTE >DEF T,PRODUCT-DESC[20],1,BYTE >DEF U,PRODUCT-DESC[21],1,BYTE >DEF V,PRODUCT-DESC[22],1,BYTE >DEF W,PRODUCT-DESC[23],1,BYTE >DEF X,PRODUCT-DESC[24],1,BYTE >UPDATE >ext a=$lookup(mytrans,a,trans) >ext b=$lookup(mytrans,b,trans) >ext c=$lookup(mytrans,c,trans) >ext D=$lookup(mytrans,D,trans) >ext E=$lookup(mytrans,E,trans) >ext F=$lookup(mytrans,F,trans) >ext G=$lookup(mytrans,G,trans) >ext H=$lookup(mytrans,H,trans) >ext I=$lookup(mytrans,I,trans) >ext J=$lookup(mytrans,J,trans) >ext K=$lookup(mytrans,K,trans) >ext L=$lookup(mytrans,L,trans) >ext M=$lookup(mytrans,M,trans) >ext N=$lookup(mytrans,N,trans) >ext O=$lookup(mytrans,O,trans) >ext P=$lookup(mytrans,P,trans) >ext Q=$lookup(mytrans,Q,trans) >ext R=$lookup(mytrans,R,trans) >ext S=$lookup(mytrans,S,trans) >ext T=$lookup(mytrans,T,trans) >ext U=$lookup(mytrans,U,trans) >ext V=$lookup(mytrans,V,trans) >ext W=$lookup(mytrans,W,trans) >ext X=$lookup(mytrans,X,trans) >xeq Update all records from the M-PRODUCT dataset [no]: YES Warning: Using DBGET for the input records IN=13, OUT=13. CPU-Sec=1. Wall-Sec=1.You can now not really read the data:
>GET M-PRODUCT >LIST >XEQ >GET M-PRODUCT (4) >OUT $NULL (0) PRODUCT-DESC = Kdbe 7*2: Nskbstew Kiwwv Drill PRODUCT-MODEL = #6523 PRODUCT-NO = 50531501 >GET M-PRODUCT (39) >OUT $NULL (1) PRODUCT-DESC = T!V Jhnmwk PRODUCT-MODEL = #7613-04 PRODUCT-NO = 50522001 >GET M-PRODUCT (49) >OUT $NULL (2) PRODUCT-DESC = Kdbe Nsk) Ki) Snmh}Kukhel Saw PRODUCT-MODEL = #4560 PRODUCT-NO = 50533001 >GET M-PRODUCT (50) >OUT $NULL (3) PRODUCT-DESC = Kdbe 2 9*8: Ubkunesk Ksa PRODUCT-MODEL = #5665 PRODUCT-NO = 50532501 >GET M-PRODUCT (52) >OUT $NULL (4) PRODUCT-DESC = T!V Uhkvewll Kukwavkbowk PRODUCT-MODEL = #9018-04 PRODUCT-NO = 50521001 >GET M-PRODUCT (103) >OUT $NULL (5) PRODUCT-DESC = Esdbms 2 9*6: Ubkunesk Kaw PRODUCT-MODEL = #5008NB PRODUCT-NO = 50512501 >GET M-PRODUCT (146) >OUT $NULL (6) PRODUCT-DESC = T!V Nskbstew Kiwwv Bby Kaw PRODUCT-MODEL = #7548-04 PRODUCT-NO = 50523001 >GET M-PRODUCT (164) >OUT $NULL (7) PRODUCT-DESC = Esdbms 9*8: Jhnmwk PRODUCT-MODEL = #3601B PRODUCT-NO = 50512001 >GET M-PRODUCT (171) >OUT $NULL (8) PRODUCT-DESC = Esdbms 7*2: Nsk) Kiwwv Vrill PRODUCT-MODEL = #DP3730 PRODUCT-NO = 50511501 >GET M-PRODUCT (221) >OUT $NULL (9) PRODUCT-DESC = Kdbe Jhnmwk PRODUCT-MODEL = #1835 PRODUCT-NO = 50532001 >GET M-PRODUCT (231) >OUT $NULL (10) PRODUCT-DESC = T!V 3 9*6: Ubkunesk Ksa PRODUCT-MODEL = #5728 PRODUCT-NO = 50522501 >GET M-PRODUCT (241) >OUT $NULL (11) PRODUCT-DESC = T!V 7*2: Nskbstew Kiwwv Drill PRODUCT-MODEL = #P1149 PRODUCT-NO = 50521501 >GET M-PRODUCT (243) >OUT $NULL (12) PRODUCT-DESC = Esdbms 9: Bby Ksa PRODUCT-MODEL = #4300 BV PRODUCT-NO = 50513001 IN=13, OUT=13. CPU-Sec=1. Wall-Sec=1.Then you can reverse the translation file key and translate fields in the table file and reverse them back: I reversed the translate fields:
>BASE STORE,1,WRITER >get m-product >TABLE MYTRANS,KEY,FILE,TRANSLTE,DATA(TRANS),HOLD There are 67 entries in MYTRANS >DEF A,PRODUCT-DESC[1],1,BYTE >DEF B,PRODUCT-DESC[2],1,BYTE >DEF C,PRODUCT-DESC[3],1,BYTE >DEF D,PRODUCT-DESC[4],1,BYTE >DEF E,PRODUCT-DESC[5],1,BYTE >DEF F,PRODUCT-DESC[6],1,BYTE >DEF G,PRODUCT-DESC[7],1,BYTE >DEF H,PRODUCT-DESC[8],1,BYTE >DEF I,PRODUCT-DESC[9],1,BYTE >DEF J,PRODUCT-DESC[10],1,BYTE >DEF K,PRODUCT-DESC[11],1,BYTE >DEF L,PRODUCT-DESC[12],1,BYTE >DEF M,PRODUCT-DESC[13],1,BYTE >DEF N,PRODUCT-DESC[14],1,BYTE >DEF O,PRODUCT-DESC[15],1,BYTE >DEF P,PRODUCT-DESC[16],1,BYTE >DEF Q,PRODUCT-DESC[17],1,BYTE >DEF R,PRODUCT-DESC[18],1,BYTE >DEF S,PRODUCT-DESC[19],1,BYTE >DEF T,PRODUCT-DESC[20],1,BYTE >DEF U,PRODUCT-DESC[21],1,BYTE >DEF V,PRODUCT-DESC[22],1,BYTE >DEF W,PRODUCT-DESC[23],1,BYTE >DEF X,PRODUCT-DESC[24],1,BYTE >UPDATE >ext a=$lookup(mytrans,a,trans) >ext b=$lookup(mytrans,b,trans) >ext c=$lookup(mytrans,c,trans) >ext D=$lookup(mytrans,D,trans) >ext E=$lookup(mytrans,E,trans) >ext F=$lookup(mytrans,F,trans) >ext G=$lookup(mytrans,G,trans) >ext H=$lookup(mytrans,H,trans) >ext I=$lookup(mytrans,I,trans) >ext J=$lookup(mytrans,J,trans) >ext K=$lookup(mytrans,K,trans) >ext L=$lookup(mytrans,L,trans) >ext M=$lookup(mytrans,M,trans) >ext N=$lookup(mytrans,N,trans) >ext O=$lookup(mytrans,O,trans) >ext P=$lookup(mytrans,P,trans) >ext Q=$lookup(mytrans,Q,trans) >ext R=$lookup(mytrans,R,trans) >ext S=$lookup(mytrans,S,trans) >ext T=$lookup(mytrans,T,trans) >ext U=$lookup(mytrans,U,trans) >ext V=$lookup(mytrans,V,trans) >ext W=$lookup(mytrans,W,trans) >ext X=$lookup(mytrans,X,trans) >xeq Update all records from the M-PRODUCT dataset [no]: YES Warning: Using DBGET for the input records IN=13, OUT=13. CPU-Sec=1. Wall-Sec=1.Now you can re-read the data since you've updated it and reversed the translation:
>GET M-PRODUCT >LIST >XEQ >GET M-PRODUCT (4) >OUT $NULL (0) PRODUCT-DESC = Skil 3/8" Variable Speed Drill PRODUCT-MODEL = #6523 PRODUCT-NO = 50531501 >GET M-PRODUCT (39) >OUT $NULL (1) PRODUCT-DESC = B&D Router PRODUCT-MODEL = #7613-04 PRODUCT-NO = 50522001 >GET M-PRODUCT (49) >OUT $NULL (2) PRODUCT-DESC = Skil Var. Sp. Auto-Scroll Saw PRODUCT-MODEL = #4560 PRODUCT-NO = 50533001 >GET M-PRODUCT (50) >OUT $NULL (3) PRODUCT-DESC = Skil 8 1/2" Circular Saw PRODUCT-MODEL = #5665 PRODUCT-NO = 50532501 >GET M-PRODUCT (52) >OUT $NULL (4) PRODUCT-DESC = B&D Cordless Screwdriver PRODUCT-MODEL = #9018-04 PRODUCT-NO = 50521001 >GET M-PRODUCT (103) >OUT $NULL (5) PRODUCT-DESC = Makita 8 1/4" Circular Saw PRODUCT-MODEL = #5008NB PRODUCT-NO = 50512501 >GET M-PRODUCT (146) >OUT $NULL (6) PRODUCT-DESC = B&D Variable Speed Jig Saw PRODUCT-MODEL = #7548-04 PRODUCT-NO = 50523001 >GET M-PRODUCT (164) >OUT $NULL (7) PRODUCT-DESC = Makita 1/2" Router PRODUCT-MODEL = #3601B PRODUCT-NO = 50512001 >GET M-PRODUCT (171) >OUT $NULL (8) PRODUCT-DESC = Makita 3/8" Var. Speed Drill PRODUCT-MODEL = #DP3730 PRODUCT-NO = 50511501 >GET M-PRODUCT (221) >OUT $NULL (9) PRODUCT-DESC = Skil Router PRODUCT-MODEL = #1835 PRODUCT-NO = 50532001 >GET M-PRODUCT (231) >OUT $NULL (10) PRODUCT-DESC = B&D 7 1/4" Circular Saw PRODUCT-MODEL = #5728 PRODUCT-NO = 50522501 >GET M-PRODUCT (241) >OUT $NULL (11) PRODUCT-DESC = B&D 3/8" Variable Speed Drill PRODUCT-MODEL = #P1149 PRODUCT-NO = 50521501 >GET M-PRODUCT (243) >OUT $NULL (12) PRODUCT-DESC = Makita 1" Jig Saw PRODUCT-MODEL = #4300 BV PRODUCT-NO = 50513001 IN=13, OUT=13. CPU-Sec=1. Wall-Sec=1.So while not really a sophisticated encryption of data it may allow you to mask some important data for test purposes.
No comments:
Post a Comment