-
-
Save allenluce/6630741 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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