title: How to convert byte array to string in swift 3
body: <p>I referred C# code for byte array to string conversion in swift</p>
  
  <pre><code>System.Text.Encoding.UTF8.GetString(encryptedpassword)
  </code></pre>
  
  <p>I tried to convert byte array to string by using below few codes:</p>
  
  <p>(A)</p>
  
  <pre><code> let utf8 : [UInt8] = [231, 13, 38, 246, 234, 144, 148, 111, 174, 136, 15, 61, 200, 186, 215, 113,0]
   let str = NSString(bytes: utf8, length: utf8.count, encoding: String.Encoding.utf8.rawValue)
   print("str : \(str)")
  </code></pre>
  
  <p>result : getting nil value </p>
  
  <p>(B)</p>
  
  <pre><code> let datastring = NSString(bytes: chars, length: count, encoding: String.Encoding.utf8.rawValue)
   print("string byte data\(chars.map{"\($0)"}.reduce(""){$0+$1})")
  </code></pre>
  
  <p>result : 23113382462341441481111741361561200186215113 (I thought this is not ideal way)</p>
  
  <p>I searched from last two days and tried other multiple ways but I missed something or doing some mistake .
  Please help me out resolved this issue.</p>
  
  <p>Referred links:
  <a href="https://stackoverflow.com/questions/29643986/how-to-convert-uint8-byte-array-to-string-in-swift">how-to-convert-uint8-byte-array-to-string-in-swift</a></p>
  
  <p><a href="https://stackoverflow.com/questions/35620543/swift-converting-byte-array-into-string"> how-to-convert-uint8-byte-array-to-string-in-swift 2</a></p>