Decryption using XOR logic

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
ramesh_dw
Participant
Posts: 21
Joined: Tue Mar 23, 2004 10:44 pm
Location: Chennai

Decryption using XOR logic

Post by ramesh_dw »

I have a requirement to decrypt a cipher text which was encrypted using an XOR function. I have to decrypt that string and load that value into an oracle table.

I could not find a relevant function call or BASIC statement using which I can write a routine. Any help is much appreciated.

I searched for XOR function in the forum and could not find any relevant post.

Thanks in advance
Ramesh
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The DataStage BASIC programmer's Guide has a description of the BITXOR (V1,V2 ) function which you can use to revert your modified string back to the original one, given you know the string with which you XOR'd in the first place.
Last edited by ArndW on Thu Jul 12, 2007 8:40 pm, edited 1 time in total.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Alternatively write your own.

Code: Select all

FUNCTION XOR(Arg1,Arg2)
Ans = (Arg1 Or Arg2) And (Not(Arg1 And Arg2))
RETURN(Ans)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ramesh_dw
Participant
Posts: 21
Joined: Tue Mar 23, 2004 10:44 pm
Location: Chennai

Post by ramesh_dw »

Thanks for the response Arnd and Ray. I tired both the solutions and the values that I get are either 0 or 1.

For example

I tried encrypting and decrypting in DataStage itself

500 is the input value
55555 is the key used for encryption..

StgEncoded=(500 Or 55555) And (Not(500 And 55555)) (turns out to be 0)

DecodedvLaue= (StgEncoded Or 55555) And (Not(StgEncoded And 55555))
(turns out to be 1)

I am expecting to get 500 back as the output of Decodedvalue. Is it possible in DataStage?

Even BITXOR seem to evaluate expressions and return either true or false.
Am I missing something?

Thanks
Ramesh
ramesh_dw
Participant
Posts: 21
Joined: Tue Mar 23, 2004 10:44 pm
Location: Chennai

Post by ramesh_dw »

BITXOR() worked for me. Thanks Arnd.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Please mark the thread as Resolved.

For future searchers, please consult the manual before using BitXOR() function; it expects two decimal integer arguments. It performs XOR on each of the corresponding pairs of bits in these integers.

Depending on what you're doing you may need to convert binary, octal or hexadecimal data to decimal before using the BitXOR() function. XTD() can be used for hexadecimal, Iconv() can be used for all three.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply