XOR – How to Build a Simple Encryption Scheme with inContact

Have you ever wanted to encrypt a message or word?  One simple way of creating your own encryption algorithm is to use the XOR operation.  The magic of the XOR is that when you XOR two numbers or characters to each other, you will get a new character or number as the result – it is effectively ‘encrypted’.  You can then ‘decrypt’ your results and restore the original value by performing a second XOR to reverse the encryption.

Say you want to encrypt the word ‘APPLE’ and you use the ‘$’ sign as your encryption key. You would perform an XOR operation on each letter of the word ‘APPLE’ in this fashion:

A XOR $

P XOR $

P XOR $

L XOR $

E XOR $

You would get the encrypted value of ‘ettha’.

To decrypt ‘ettha’ you would simply reverse the operation as shown.

e XOR $

t XOR $

t XOR $

h XOR $

a XOR $

You would be rewarded with the word ‘APPLE’.

**Be sure to NEVER use an encryption character as a key that might appear in your messages that you are trying to encrypt.  That character will be lost.

Using XOR, you can create a set of encryption keys that you determine.  In this fashion, it is possible to perform simple encryption within a script and store that encrypted value within your contacts – just be certain you don’t lose the encryption key.  The trick to performing an XOR operation is that you must use VB script in a SHELL action.  An example is shown below.

TLEN = Len(P2)

For x = 1 To TLEN

TVAL = Mid$(P2, x, 1)

TVALINT = Asc(TVAL)

TVALINT = TVALINT Xor Asc(P1)

P3 = P3 & Chr(TVALINT)

Next x

Assign P3, "EVAL2"

In this example we pass the word or message to be encrypted into the SHELL action as the variable ‘P2’ and our encryption key is in the value ‘P1’.   We then parse each character of P2 and perform an XOR action against P1 and reconstruct the new encrypted message in the variable P3.  P3 can then be stored as a published variable within the contact.

InContact provides its users with a powerful array of programming tools, including Boolean operations like AND, OR and XOR.  These can be employed to build truth tables or even create simple encryption schemes.

Call us at 1-866-965-7227 to talk to a specialist
Call
Live chat with a specialist
Chat
Learn more about our solutions
Request a Quote