]>
code.delx.au - monosys/blob - scripts/psi-password.py
3b4d34a083e6a2d0f50a5819d15b9ada3b6bd249
2 # Copyright 2007 James Bunton <jamesbunton@fastmail.fm>
3 # Licensed for distribution under the GPL version 2, check COPYING for details
4 # Decodes a password taken from a Psi config.xml file
9 def decodePassword(passwd
, key
):
15 while n1
< len(passwd
):
17 if n1
+ 4 > len(passwd
):
19 x
+= int(passwd
[n1
+0], 16) * 4096
20 x
+= int(passwd
[n1
+1], 16) * 256
21 x
+= int(passwd
[n1
+2], 16) * 16
22 x
+= int(passwd
[n1
+3], 16) * 1
23 result
+= chr(x ^
ord(key
[n2
]))
31 if __name__
== "__main__":
36 print >> sys
.stderr
, "Usage: %s passwd jid" % sys
.argv
[0]
38 print decodePassword(passwd
, key
)