Blob.InnerShiftXor

Parent Previous Next

Blob.InnerShiftXor.

All the bytes in the blob participate in an internal ShiftXor operation with each other and return a single byte as the result.


The ShiftXor operates on each byte in a sequential order starting at index 0 by first doing a 1 bit Shift to the left and then an Xor with the next byte, then the result does a 1 bit Shift before an Xor with the next byte and so forth.


Syntax.


 InnerShiftXor() : Byte

 


Example:


 //Please notice how we use the same 4 bytes in a slightly different order,

 //which produces completely different results.


 Byte A := (0x01030507).InnerShiftXor(); //Now A == 0x09;

 Byte B := (0x07010305).InnerShiftXor(); //Now B == 0x3F;



 //Calculation A:


 //0x01 ~ 0000 0001

 //---------------- Shift 1 left

 //       0000 0010      

 //0x03 ~ 0000 0011

 //---------------- Xor

 //       0000 0001

 //---------------- Shift 1 left

 //       0000 0010

 //0x05 ~ 0000 0101

 //---------------- Xor

 //       0000 0111

 //---------------- Shift 1 left

 //       0000 1110

 //0x07 ~ 0000 0111

 //---------------- Xor

 //0x09 ~ 0000 1001

 //================



 //Calculation B:


 //0x07 ~ 0000 0111

 //---------------- Shift 1 left

 //       0000 1110      

 //0x01 ~ 0000 0001

 //---------------- Xor

 //       0000 1111

 //---------------- Shift 1 left

 //       0001 1110

 //0x03 ~ 0000 0011

 //---------------- Xor

 //       0001 1101

 //---------------- Shift 1 left

 //       0011 1010

 //0x05 ~ 0000 0101

 //---------------- Xor

 //0x3F ~ 0011 1111

 //================




As demonstrated this operation is very dependent on the order of the bytes, which may be desirable for ripple effects etc.