title: Cannot implicitly convert type 'int' to 'byte'. An explicit conversion exists (are you missing a cast?) when compile
body: <p>I`m not a guru in c and I need some help.
  I have this code:</p>
  
  <pre><code>{
      private ushort InCounter;
  
      private ushort OutCounter;
  
      private byte[] cipherKey1 = new byte[256];
  
      private byte[] cipherKey2 = new byte[256];
  
      public AuthCipher()
      {
          byte baseKey = 157;
          byte baseKey2 = 98;
          for (int i = 0; i &lt; 256; i++)
          {
              this.cipherKey1[i] = baseKey;
              this.cipherKey2[i] = baseKey2;
              baseKey = (15 + baseKey * 250) * baseKey + 19;
              baseKey2 = (121 - baseKey2 * 92) * baseKey2 + 109;
          }
          this.InCounter = 0;
          this.OutCounter = 0;
      }
  
      public unsafe void Encrypt(byte* src, int srcOffset, byte[] dst, int dstOffset, int length)
      {
          fixed (byte* pDst = &amp;dst[dstOffset])
          {
              for (int i = srcOffset; i &lt; srcOffset + length; i++)
              {
                  pDst[i] = (src[i] ^ 171);
                  pDst[i] = (byte)(pDst[i] &gt;&gt; 4 | (int)pDst[i] &lt;&lt; 4);
                  byte* expr_39 = pDst + i;
                  *expr_39 ^= this.cipherKey2[this.InCounter &gt;&gt; 8];
                  byte* expr_51 = pDst + i;
                  *expr_51 ^= this.cipherKey1[(int)(this.InCounter &amp; 255)];
                  this.InCounter += 1;
              }
          }
      }
  
      public unsafe void Decrypt(byte[] src, int srcOffset, byte* dst, int dstOffset, int length)
      {
          fixed (byte* pSrc = &amp;src[srcOffset])
          {
              for (int i = dstOffset; i &lt; dstOffset + length; i++)
              {
                  dst[i] = (pSrc[i] ^ 171);
                  dst[i] = (byte)((int)dst[i] &lt;&lt; 4 | dst[i] &gt;&gt; 4);
                  byte* expr_35 = dst + i;
                  *expr_35 ^= this.cipherKey2[this.OutCounter &gt;&gt; 8];
                  byte* expr_4C = dst + i;
                  *expr_4C ^= this.cipherKey1[(int)(this.OutCounter &amp; 255)];
                  this.OutCounter += 1;
              }
          }
      }
  }
  </code></pre>
  
  <p>Errors pop in:</p>
  
  <pre><code>baseKey = (15 + baseKey * 250) * baseKey + 19;
              baseKey2 = (121 - baseKey2 * 92) * baseKey2 + 109;
  
  pDst[i] = (src[i] ^ 171);
  dst[i] = (pSrc[i] ^ 171);
  </code></pre>
  
  <p>Tried already to read some other answers to this question bu no luck.
  If any one could help me in understand whats wrong probably I know how to fix it :)</p>
  
  <p>Any help will be appreciated.</p>