Changeset 10:2f86257dcb15 in ralphm-patches


Ignore:
Timestamp:
Apr 9, 2009, 2:47:30 PM (11 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Message:

Make sure digests work on older python versions, too.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • s2s.patch

    r9 r10  
    11diff -r 313d45b505a7 wokkel/server.py
    22--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
    3 +++ b/wokkel/server.py  Thu Apr 09 12:03:24 2009 +0200
    4 @@ -0,0 +1,700 @@
     3+++ b/wokkel/server.py  Thu Apr 09 14:47:05 2009 +0200
     4@@ -0,0 +1,702 @@
    55+# -*- test-case-name: wokkel.test.test_server -*-
    66+#
     
    1919+try:
    2020+    from hashlib import sha256
     21+    digestmod = sha256
    2122+except ImportError:
    22 +    from Crypto.Hash.SHA256 import new as sha256
     23+    import Crypto.Hash.SHA256 as digestmod
     24+    sha256 = digestmod.new
    2325+
    2426+import hmac
     
    6365+    hashedSecret = hashObject.hexdigest()
    6466+    message = " ".join([receivingServer, originatingServer, streamID])
    65 +    hash = hmac.HMAC(hashedSecret, message, digestmod=sha256)
     67+    hash = hmac.HMAC(hashedSecret, message, digestmod=digestmod)
    6668+    return hash.hexdigest()
    6769+
     
    705707diff -r 313d45b505a7 wokkel/test/test_server.py
    706708--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
    707 +++ b/wokkel/test/test_server.py        Thu Apr 09 12:03:24 2009 +0200
     709+++ b/wokkel/test/test_server.py        Thu Apr 09 14:47:05 2009 +0200
    708710@@ -0,0 +1,450 @@
    709711+# Copyright (c) 2003-2008 Ralph Meijer
Note: See TracChangeset for help on using the changeset viewer.