Skip to content

Instantly share code, notes, and snippets.

@gccyugi
Created May 31, 2012 03:38
Show Gist options
  • Save gccyugi/2840790 to your computer and use it in GitHub Desktop.
Save gccyugi/2840790 to your computer and use it in GitHub Desktop.
huami-python
#!/usr/bin/env python
#coding=utf8
import sys
import hmac
STR1 = 'snow'
STR2 = 'kise'
STR3 = 'sunlovesnow1990090127xykab'
def huami(password, key):
md5one = hmac.new(key, password).hexdigest()
md5two = hmac.new(STR1, md5one).hexdigest()
md5three = hmac.new(STR2, md5one).hexdigest()
rule = list(md5three)
source = list(md5two)
for i in range(0, 32):
if rule[i] in STR3:
source[i] = source[i].upper()
code32 = ''.join(source)
if source[0].isdigit():
code16 = 'K' + ''.join(source[1:16])
else:
code16 = ''.join(source[0:16])
return code16, code32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment