将以下代码从C转换为VB.NET

时间:2011-01-22 21:22:37

标签: c vb.net

嘿伙计们,
能否请您帮我把以下C代码转换成VB.NET。我觉得这很简单......但我的C知识非常有限!

任何帮助都会很棒! 感谢

buf[0] = (num1 & 0xff000000) >> 24;  
buf[1] = (num1 & 0xff0000) >> 16;  
buf[2] = (num1 & 0xff00) >> 8;  
buf[3] =  num1 & 0xff;

buf[4] = (num2 & 0xff000000) >> 24;  
buf[5] = (num2 & 0xff0000) >> 16;  
buf[6] = (num2 & 0xff00) >> 8;  
buf[7] =  num2 & 0xff;  

strncpy(buf+8, headers->key3, 8);  
buf[16] = '\0';  

md5_buffer(buf, 16, target);  
target[16] = '\0';

1 个答案:

答案 0 :(得分:3)

byte[] temp1 = BitConvert.GetBytes(num1);
byte[] temp2 = BitConvert.GetBytes(num2);

Array.Copy(temp1, 0, buf, 0, 4);
Array.Copy(temp2, 0, buf, 4, 4);

Array.Copy(buf, 8, headers.key3, 0, 8)
buf[16] = 0;

Array.Copy(buf, target, 16)
target[16] = 0;

Using MD5 hasher = new MD5CryptoServiceProvider()
    target = hasher.ComputeHash(buf);
End Using