title: Understanding why certain bit manipulation operations are performed
body: <p>Below is the source code of Keytab implementation in Java. This snippet reads the key version from the keytab file. I am having trouble understanding how this works.
  Why is the bitwise AND and shift left operation performed?</p>
  
  <p>What my code calls: </p>
  
  <pre><code>KeyTab keytab = KeyTab.getInstance(keytabFile); // passing keytab file location. 
  </code></pre>
  
  <p>This file is in binary format. KeyTabInputStream reads the data.</p>
  
  <pre class="lang-java prettyprint-override"><code>  private void load(KeyTabInputStream var1) throws IOException, RealmException {
          this.entries.clear();
          **this.kt_vno = var1.readVersion();**
          if (this.kt_vno == 1281) {
              var1.setNativeByteOrder();
          }
  
          boolean var2 = false;
  
          while(var1.available() &gt; 0) {
              int var4 = var1.readEntryLength();
              KeyTabEntry var3 = var1.readEntry(var4, this.kt_vno);
              if (DEBUG) {
                  System.out.println("&gt;&gt;&gt; KeyTab: load() entry length: " + var4 + "; type: " + (var3 != null ? var3.keyType : 0));
              }
  
              if (var3 != null) {
                  this.entries.addElement(var3);
              }
          }
  
      }
  </code></pre>
  
  <pre class="lang-java prettyprint-override"><code>    public int readVersion() throws IOException {
          int var1 = (this.read() &amp; 255) &lt;&lt; 8;
          return var1 | this.read() &amp; 255;
      }
  </code></pre>