Skip to content

Instantly share code, notes, and snippets.

@allenluce
Created September 19, 2013 22:28
Show Gist options
  • Save allenluce/6630741 to your computer and use it in GitHub Desktop.
Save allenluce/6630741 to your computer and use it in GitHub Desktop.
import javax.xml.bind.DatatypeConverter;
import java.security.MessageDigest;
class Odin {
public static void main (String[] args) {
String mac_address = "10:D5:42:E3:D5:34";
System.out.println(odin(mac_address));
}
public static String odin(String mac_address) {
mac_address = mac_address.replaceAll("[^0-9a-zA-Z]", "");
MessageDigest md = null;
try {
md = MessageDigest.getInstance("SHA-1");
} catch(Exception e) {}
byte[] binary_sha = md.digest(DatatypeConverter.parseHexBinary(mac_address));
return DatatypeConverter.printHexBinary(binary_sha).toLowerCase();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment