2014-04-10 81 views
1

使用onvif密码必须以某种方式加密。 35页的ONVIF Appicaltion Programmer's Guide描述的方法,我也发现了如何在PHP中做到这一点,它看起来像这样:如何在python中为onvif做密码加密?

$nonce  = pack('H*', mt_rand()); 
$passdigest = base64_encode(pack('H*', sha1($nonce . pack('a*', timestamp) . pack('a*', password)))); 

的主要问题是,我不知道所有的字节操作是如何工作的,所以我需要一些帮助到蟒蛇传递这个PHP代码...

回答

1

来自:https://github.com/Pegax/pyOnvif

n64 = ''.join(SystemRandom().choice(string.letters + string.digits+string.punctuation) for _ in range(22)) 
nonce = base64.b64encode(n64) 
#n64 = base64.b64decode(nonce) 
pdigest= base64.b64encode(sha1(n64+created+self.password).digest())