chiark / gitweb /
Merge playlist support.
[disorder] / python / disorder.py.in
index 3e1541eaf97104d29ab3bcf46679fd6b4fb17b78..d06c7eef7f5773d2f205187f58dabd5b47626f1e 100644 (file)
@@ -50,7 +50,7 @@ import os
 import pwd
 import socket
 import binascii
-import sha
+import hashlib
 import sys
 import locale
 
@@ -66,6 +66,18 @@ _unquoted = re.compile("[^\"' \\t\\n\\r][^ \t\n\r]*")
 
 _response = re.compile("([0-9]{3}) ?(.*)")
 
+# hashes
+_hashes = {
+  "sha1": hashlib.sha1,
+  "SHA1": hashlib.sha1,
+  "sha256": hashlib.sha256,
+  "SHA256": hashlib.sha256,
+  "sha384": hashlib.sha384,
+  "SHA384": hashlib.sha384,
+  "sha512": hashlib.sha512,
+  "SHA512": hashlib.sha512,
+};
+
 version = "_version_"
 
 ########################################################################
@@ -387,8 +399,7 @@ class client:
             password = self.config['password']
           else:
             password = self.password
-          # TODO support algorithms other than SHA-1
-          h = sha.sha()
+          h = _hashes[algo]()
           h.update(password)
           h.update(binascii.unhexlify(challenge))
           self._simple("user", user, h.hexdigest())