Skip to content

Instantly share code, notes, and snippets.

@toidang92
Forked from rajkosto/odi_keygen.py
Created September 7, 2024 14:59
Show Gist options
  • Save toidang92/b75e2dd0371b4206003ecaf99c371f5c to your computer and use it in GitHub Desktop.
Save toidang92/b75e2dd0371b4206003ecaf99c371f5c to your computer and use it in GitHub Desktop.
ODI SFP XPON stick MAC_KEY generator
#!/usr/bin/env python3
#ODI DFP-34X-2C2 MAC_KEY key generator by rajkosto
import sys
import string
import hashlib
args = sys.argv
if len(args) != 2:
sys.exit("Usage: odi_keygen.py YOURMACADDR")
macAddr = args[1].strip().replace(':','')
if len(macAddr) != 12:
sys.exit("Mac address must be 12 hex digits (6 bytes)")
if not all(c in string.hexdigits for c in macAddr):
sys.exit("Mac address can only contain 0-9, A-F characters (hex digits)")
cmacPrefix = 'hsgq1.9a'
hashText = cmacPrefix+macAddr.upper()
encodedText = hashText.encode('ascii')
md5Hash = hashlib.md5(encodedText).digest().hex()
print('ELAN_MAC_ADDR='+macAddr.lower())
print('MAC_KEY='+md5Hash.lower())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment