WTF? Can some .NET guru help me out?

Recently I had to figure out some VB.NET code and port it to C#. I am not much of a VB guy, but I figured I could understand some basic stuff. I am having some difficulties, and was hoping someone could explain the brain dead issue I am having. Here is the VB.NET code: Sub Main() Dim key_aes128 As String key_aes128 = Chr(&H5S) & Chr(&H4S) & Chr(&H57S) & Chr(&HF0S) & Chr(&H5CS) & Chr(&HADS) & Chr(&H9AS) & Chr(&H55S) & Chr(&H5S) & Chr(&H4S) & Chr(&H17S) & Chr(&HF0S) & Chr(&H5CS) & Chr(&HADS) & Chr(&H9AS) & Chr(&H55S) End Sub Here is the C# code I am trying: static void Main(string[] args) { string key_aes128; key_aes128 = String.Format( “{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}”, Chr(0x5), Chr(0x4), Chr(0x57), Chr(0xF0), Chr(0x5C), Chr(0xAD), Chr(0x9A), Chr(0x55), Chr(0x5), Chr(0x4), Chr(0x17), Chr(0xF0), Chr(0x5C), Chr(0xAD), Chr(0x9A), Chr(0x55) ); } static Char Chr(int i) { return Convert.ToChar(i); } You would THINK that key_aes128 would be the same. They are CLOSE…. but not actually the same. Anyone know what the heck I am doing wrong? It SHOULD result in the exact same string….

Leave a Reply

Your email address will not be published. Required fields are marked *