谁帮我把这段C代码转化为JAVA
这是一段C的代码,分别是两个函数,第二个是将一个MAC地址转化为一个6位的字符,第一个函数是将6位的字符转化为对应的MAC地址,相当于是一个加密解密的过程,请高手帮我把这段C转化为JAVA,谢谢! //// 6 -> mac
void ui_mac_ntoa(const unsigned char *n, char *a, const char *d)
{
sprintf(a, "%02x%s%02x%s%02x%s%02x%s%02x%s%02x", n[0], d, n[1], d, n[2], d, n[3], d, n[4], d, n[5]);
}
//////mac -> 6
void ui_mac_aton(const char *a, unsigned char *n, const char *d)
{
char buf[30] = {0};
const char *upper = buf;
char ch[3] = {0};
int nf = 0, ns = 0, nt = 2 + strlen(d);
strcpy(buf, a);
ui_strupper(buf);
for (unsigned int index = 0; index < 6; index++) {
strncpy(ch, upper + index * nt, 2);
nf = (ch[0] >= '0' && ch[0] <= '9') ? (ch[0] - '0') : (ch[0] - 'A') + 10;
ns = (ch[1] >= '0' && ch[1] <= '9') ? (ch[1] - '0') : (ch[1] - 'A') + 10;
*(n + index) = (unsigned char)(nf * 16 + ns);
}
}