Excellent! Now all I need to do is try to understand what this code means ...
1) what is a "long" data type? Is it a "word"?
2) what does the * symbol represent here: long* v
3) What's the DBPro equivilent of an unsigned long?
4) what does the following mean? -->
Actually, there's quite a lot there for me to learn. To save us all time, is it possible to port this code into DBPro?
Encode:
void code(long* v, long* k) {
unsigned long y=v[0],z=v[1], sum=0, /* set up */
delta=0x9e3779b9, n=32 ; /* a key schedule constant */
while (n-->0) { /* basic cycle start */
sum += delta ;
y += (z<<4)+k[0] ^ z+sum ^ (z>>5)+k[1] ;
z += (y<<4)+k[2] ^ y+sum ^ (y>>5)+k[3] ; /* end cycle */
}
v[0]=y ; v[1]=z ; }
Decode:
void decode(long* v,long* k) {
unsigned long n=32, sum, y=v[0], z=v[1],
delta=0x9e3779b9 ;
sum=delta<<5 ;
/* start cycle */
while (n-->0) {
z-= (y<<4)+k[2] ^ y+sum ^ (y>>5)+k[3] ;
y-= (z<<4)+k[0] ^ z+sum ^ (z>>5)+k[1] ;
sum-=delta ; }
/* end cycle */
v[0]=y ; v[1]=z ; }
Cheers!