title: Cryptographic code in CSharp similar to code in Go (AES,CFB,XorKeyStream)
body: <p>I have cryptographic code in Go but I can't hard find similar code in CSharp.
  I am debating to make my own implementation of XorKeyStream but I am told that there is legal issue if I write my own cryptographic code. I am sure there must be similar code in CSharp.</p>
  
  <pre><code>package main
  
  import (
      "crypto/aes"
      "crypto/cipher"
      "fmt"
  )
  
  func main() {
  
      k1 := []byte("0123456789abcdef")
      r1 := []byte("1234567890abcdef")
      data := []byte("0123456789")
      fmt.Printf("original %x %s\n", data, string(data))
  
      {
          block, _ := aes.NewCipher(k1)
          stream := cipher.NewCFBEncrypter(block, r1)
          stream.XORKeyStream(data, data)
          fmt.Printf("crypted %x\n", data)
      }
      {
          block, _ := aes.NewCipher(k1)
          stream := cipher.NewCFBDecrypter(block, r1)
          stream.XORKeyStream(data, data)
          fmt.Printf("decrypted %x %s\n", data, string(data))
      }
  
  }
  </code></pre>
  
  <p><a href="http://play.golang.org/p/EnJ56dYX_-" rel="nofollow">http://play.golang.org/p/EnJ56dYX_-</a></p>
  
  <p><strong>output</strong></p>
  
  <pre><code>original 30313233343536373839 0123456789
  crypted 762b6dcea9c2a7460db7
  decrypted 30313233343536373839 0123456789
  </code></pre>
  
  <p><strong>PS</strong>
  Some people marked that question as possible duplicate of question: "C# AES: Encrypt a file causes “Length of the data to encrypt is invalid.” error" 
  I look for identical code in CSharp for existing code in Go. That question is about padding. This algorithm needs "Key stream" that will xor text. 
  It is different questions.</p>