Advertisement
ZeekoSec

String2Byte

Apr 8th, 2015
516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.43 KB | None | 0 0
  1. Private Shared Function GetBytes(str As String) As Byte()
  2.     Dim bytes As Byte() = New Byte(str.Length * 2 - 1) {}
  3.     System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length)
  4.     Return bytes
  5. End Function
  6.  
  7. Private Shared Function GetString(bytes As Byte()) As String
  8.     Dim chars As Char() = New Char(bytes.Length / 2 - 1) {}
  9.     System.Buffer.BlockCopy(bytes, 0, chars, 0, bytes.Length)
  10.     Return New String(chars)
  11. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement