CHARXOR()
Combine corresponding ASCII value of two strings with bitwise XOR
Syntax
CHARXOR( <[@]cString1>, <cString2> ) --> cXOrString
Arguments
<[@]cString1> first string <cString2> second string
Returns
<cXOrString> string with bitwise XOR combined ASCII values
Description
The CHARXOR() function constructs a new string from the two strings passed as parameters. To do this, it combines the ASCII values of the corresponding characters of both strings with a bitwise XOR-operation and places a character in the resulting string whose ASCII value equals to the result of that operation. If the first string is passed by reference, the resulting string is stored in <cString1>, too. By setting the CSETREF()-switch to .T., the return value can be omitted. If <cString2> is shorter than <cString1> and the last character of <cString2> has been processed, the function restarts with the first character of <cString2>.
Examples
// easy encryption ? charxor( "This is top secret !", "My Password" ) // --> <encrypted sentence>
Tests
charxor( charxor( "This is top secret !", "My Password" ), "My Password" ) == "This is top secret !"
Compliance
CHARXOR() is compatible with CT3’s CHARXOR().
Platforms
All
Files
Source is charop.c, library is ct3.
Seealso
CHARADD(), CHARSUB(), CHARNOT(), CHARAND(), CHAROR(), CHARSHL(), CHARSHR(), CHARRLL(), CHARRLR(), CSETREF()