/// <summary> /// Read data from the stream and encrypt it. /// </summary> /// <param name="buffer">The buffer to read into.</param> /// <param name="offset">The offset in the buffer to begin storing data.</param> /// <param name="count">The number of bytes to read.</param> /// <returns></returns> public override int Read(byte[] buffer, int offset, int count) { int bytesRead = stream.Read(buffer, offset, count); if (target == Target.Normal) { bf.Encipher(buffer, bytesRead); } else { bf.Decipher(buffer, bytesRead); } return(bytesRead); }
public static byte[] encodeVolumeData(ulong intToneVolume, UInt32 dongleID) { byte[] keyArr = Encoding.ASCII.GetBytes(key); byte[] defaultEncrypted = writeInkData(intToneVolume, dongleID); Blowfish blowFish = new Blowfish(keyArr); byte[] result = new byte[16]; result = blowFish.Encipher(defaultEncrypted, defaultEncrypted.Length); return(result); }