ext); Convert.ToByte (replacement [t]) ;
}
//зворотна операція PHT (Pseudo Hadamard Transform) byte [] IPHT (byte x1, byte x2)
{intX1=Convert.ToInt32 (x1); intX2=Convert.ToInt32 (x2); diff1=-intX1 + 2 * intX2; (diff1 lt; 0) +=256; diff2=intX1 -intX2; (diff2 lt; 0) +=256; intY1=diff1% 256; intY2=diff2% 256; [] b=new byte [2]; [1]=Convert.ToByte (intY1); [0]=Convert.ToByte (intY2); b;
}
//операція PHT (Pseudo Hadamard Transform) byte [] PHT (byte x1, byte x2)
{intX1=Convert.ToInt32 (x1); intX2=Convert.ToInt32 (x2); intY1=(2 * intX1 + intX2)% 256; intY2=(intX1 + intX2)% 256; [ ] b=new byte [2]; [0]=Convert.ToByte (intY1); [1]=Convert.ToByte (intY2); b;
} byte [] execPHTStage (byte [] x, int round)
{[] b=new byte [8]; [] temp=new byte [2];=this.PHT (x [0], x [1]); (round!=0 )
{[0]=temp [0]; [4]=temp [1];
}
{. Copy (temp, 0, b, 0, 2);
}=this.PHT (x [2], x [3]); (round!=0)
{[1]=temp [0]; [5]=temp [1];
}
{. Copy (temp, 0, b, 2, 2);
}=this.PHT (x [4], x [5]); (round!=0)
{[2]=temp [0]; [6]=temp [1];
}
{. Copy (temp, 0, b, 4, 2);
}=this.PHT (x [6], x [7]); (round!=0)
{[3]=temp [0]; [7]=temp [1];
}
{. Copy (temp, 0, b, 6, 2);
} b;
} byte [] execIPHTStage (byte [] x, int round)
{[] b=new byte [8]; [] temp=new byte [2];=this.IPHT (x [0], x [1]); (round!=0 )
{[0]=temp [0]; [2]=temp [1];
}. Copy (temp, 0, b, 0, 2);=this.IPHT (x [2], x [3]); (round!=0)
{[4]=temp [0]; [6]=temp [1];
}. Copy (temp, 0, b, 2, 2);=this.IPHT (x [4], x [5]); (round!=0)
{[1]=temp [0]; [3]=temp [1];
}. Copy (temp, 0, b, 4, 2);=this.IPHT (x [6], x [7]); (round!=0)
{[5]=temp [0]; [7]=temp [1];
}. Copy (temp, 0, b, 6, 2); b;
}
//шифрування SAFER K - 64byte [] encrypt ()
{sourceLength=this.GetTextBlockLength (this.Text); [] key=Encoding.Default.GetBytes (this.Key); [] bigKey; [] bigKey2; [] sourceBlock=new byte [ 8]; [] result=new byte [sourceLength * 8]; (int round=0; round lt; this.Round; round ++)
{r=0; (int i=0; i lt; sourceLength; i ++)
{= this.GetTextBlock8Byte (this.Text, i);
//поліпшення ключа шифрування=this.GetKey (2 * (i + 1) - 1, key);=this.GetKey (2 * (i + 1), key); (int j =0; j lt; sourceBlock.Length; j ++)
{(j + 1)
{1: 4: 5: 8: [r]=this.XOR (sourceBlock [j], bigKey [j]); [r]=this.E (result [r]); [r]=this.Mod256 (result [r], bigKey2 [j]) ;;: [r]=this.Mod256 (sourceBlock [j], bigKey [j]); [r]=this.L (result [ r]); [r]=this.XOR (result [r], bigKey2 [j]) ;;
} ++;
} [] temp=new byte [8] ;. Copy (result, r - 8, temp, 0, 8);=this.execPHTStage (temp, 1);=this.execPHTStage (temp, 2);=this.execPHTStage (temp, 0) ;. Copy (temp, 0, result, r - 8, 8);
}
} result;
}
//дешифрування SAFER K - 64byte [] decrypt ()
{sourceLength=this.GetTextBlockLength (this.Text); [] key=Encoding.Default.GetBytes (this.Key); [] bigKey; [] bigKey2; [] sourceBlock=new byte [ 8]; [] result=new byte [sourceLength * 8]; (int round=0; round lt; this.Round; round ++)
{r=0; (int i=0; i lt; sourceLength; i ++)
{= this.GetTextBlock8Byte (this.Text, i); [] temp=new byte [8] ;. Copy (sourceBlock, 0, temp, 0, 8);=this.execIPHTStage ( sourceBlock, 1);=this.execIPHTStage (temp, 2);=this.execIPHTStage (temp, 0) ;. Copy (temp, 0, result, r, 8);=this.GetKey (2 * (i + 1 ) - 1, key);=this.GetKey (2 * (i + 1), key); (int j=0; j lt; sourceBlock.Length; j ++)
{(j + 1)
{1: 4: 5: 8: [r]=this.DiffMod256 (result [r], bigKey2 [j]); [r]=this.L (result [r]); [r]=this.XOR (result [r], bigKey [j]) ;;: [r]=this.XOR (result [r], bigKey2 [j]); [r]=this.E (result [ r]); [r]=this.DiffMod256 (result [r], bigKey [j]) ;;
} ++;
}
}
} result;
} <...