如何将Mac地址转换为oui查找格式

时间:2019-06-25 05:24:50

标签: java mac-address

我有一个import SwiftUI struct ContentView : View { @State var length: Float = 20 var body: some View { NavigationView { List { PasswordGeneratorSettings(length: $length) }.navigationBarTitle(Text("Settings")) } } } struct PasswordGeneratorSettings : View { @Binding var length: Float var body: some View { VStack(alignment: .leading) { Slider(value: $length, from: 1, through: 512, by: 1) Text("Password Length: \(Int(length))") } } } 格式的mac address,现在在我的80:ad:16:c5:a6:28数据库中,下载的Mac供应商的mac id从oui0

问题是:

  

如何转换我的mac地址以匹配数据库中的mac地址?

1 个答案:

答案 0 :(得分:0)

提取mac地址的前3个字节并将十六进制转换为十进制。

String mac = "80:ad:16:c5:a6:28";
String[] byteStr = mac.split(":");
int identifier = Integer.parseInt(byteStr[0],16) * 256 * 256 + Integer.parseInt(byteStr[1],16) * 256 + Integer.parseInt(byteStr[2],16);