public string Encrypt(string tcStr, string tcPassword) { byte[] tcStrBytes = Encoding.ASCII.GetBytes(tcStr); int tcStrLength = tcStrBytes.Length; string lcPassword = tcPassword + ((char) 0).ToString(); byte[] lcPasswordBytes = Encoding.ASCII.GetBytes(lcPassword); int lnPassLen = lcPasswordBytes.Length; int lnPassPos = 0; string lcStrOut = string.Empty; int lnPassNum = ((CipherGetPnum(tcPassword)/997 - 1)%254) + 1; for (int i = 0; i < tcStrLength; i++) { int lnNum01 = ((lnPassNum + (i - tcStrLength)) - 1); lnPassNum = (Math.Abs(lnNum01)%254)*Math.Sign(lnNum01) + 1; var lnByte = tcStrBytes[i] ^ (lnPassNum ^ lcPasswordBytes[lnPassPos]); lcStrOut = lcStrOut + Convert.ToChar(lnByte==0 ? tcStrBytes[i] : lnByte & 0xFF); lnPassPos = lnPassPos > lnPassLen ? 0 : lnPassPos + 1; } return lcStrOut; }Quick test comparing results with the VFP version using string 'Test' and password 'Viv' shows identical results in VFP (returned asc values: 255,246,253,131) i.e. string length is 4. Your C# only returns first three values (i.e. string length 3)