Mr-Markus / ZigbeeNet

A .NET Standard library for working with ZigBee
Eclipse Public License 1.0
130 stars 46 forks source link

ZigBeeKey(string keyString) doesn't correctly parse hex #163

Closed genesiscz closed 2 years ago

genesiscz commented 2 years ago

Getting

Unhandled exception. System.FormatException: Input string was not in a correct format. at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type) at System.Byte.Parse(String s) at Program.T(String keyString) at Program.Main()

because of this line

https://github.com/Mr-Markus/ZigbeeNet/blob/723b76e699317c6c5c16b5a339a64f29821925ec/libraries/ZigBeeNet/Security/ZigBeeKey.cs#L67

Should probably be

        Key[i / 2] = byte.Parse(curr.ToString(), NumberStyles.HexNumber);

Fiddle: https://dotnetfiddle.net/bwRkPF

Mr-Markus commented 2 years ago

Please send a PR for this