Skip to content

Instantly share code, notes, and snippets.

@rajkosto
Created November 18, 2022 12:56
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save rajkosto/29c513b96ea6262d2fb1f965a52ce16f to your computer and use it in GitHub Desktop.
Save rajkosto/29c513b96ea6262d2fb1f965a52ce16f 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())
@valemal
Copy link

valemal commented Dec 23, 2022

Hello. Write a better generator to work from under Windows

@rajkosto
Copy link
Author

works just fine on windows thats what i use and what i made it on...

@MarinSNB
Copy link

How do I use this script? Can provide some steps? Thank you so much!

@zentavr
Copy link

zentavr commented Mar 29, 2023

@MarinSNB you can download python installer for windows at python.org.

@MarinSNB
Copy link

Thank you so much!

@physx2494
Copy link

If I'm correct, it generates MAC_KEY from a given MAC_ADDR, right?

@zentavr
Copy link

zentavr commented Apr 9, 2023

@physx2494 correct

@Blacktimess
Copy link

Thanks! Just what I needed for my DFP-34G-2C2

@akeyx
Copy link

akeyx commented Oct 25, 2023

Here's a one liner bash version:
mac="xx:xx:xx:xx:xx:xx";MAC=${mac^^};echo -n "hsgq1.9a${MAC//:/}"|md5sum

@wilfrido99
Copy link

Alguém poderia me ajudar a criar uma Mackey para meu MacAddress: Mac: F4:54:20:D8:36:C1

@akeyx
Copy link

akeyx commented Mar 6, 2024

Alguém poderia me ajudar a criar uma Mackey para meu MacAddress: Mac: F4:54:20:D8:36:C1

$ mac="F4:54:20:D8:36:C1";MAC=${mac^^};echo -n "hsgq1.9a${MAC//:/}"|md5sum
b62d86edd98a504079caf2bf87da5ab3  -

@wilfrido99
Copy link

Thank you my friend @akeyx, I needed it for my Xpon stick.

@wilfrido99
Copy link

Could you tell me what software you used to run the script?

@akeyx
Copy link

akeyx commented Mar 7, 2024

The bash shell.

@ddsofiane
Copy link

Could anyone help me create a Mackey for my MacAddress: Mac:B8:DD:71:D6:D7:6E
thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment