Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MAC address in C#

public static NDIS_802_3_ADDRESS StrToByteArray(string str)
{
    ASCIIEncoding encoding = new ASCIIEncoding();
    byte[] m = encoding.GetBytes(str);
    NDIS_802_3_ADDRESS mac = new NDIS_802_3_ADDRESS(m);
    return mac;
}

You use these method in order to change string to mac address, however the output of that is fixed value 30-30-2D-32-31-2D, whatever the input string.

Any ideas?


1 Answers

It's probably returning the MAC address for your network interface card.

If you're on windows, from the command line run ipconfig /all. Does that match the value you are being returned?

I'm not really sure what this method is supposed to do in the first place. What are you passing in as the input string and what do you expect this method to do?

like image 99
blak3r Avatar answered Mar 16 '26 03:03

blak3r



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!