# Path: wire/utils.py
# def autoinc(redis, key):
#     key = "_incs:%s" % key
#     if not redis.exists(key):
#         redis.set(key, 0)
# 
#     return redis.incr(key)
# 
# Path: wire/utils.py
# class Hasher:
#     def __init__(self, strength=16):
#         self._strength = strength
# 
#     def hash(self, password, salt=False, encode=True):
#         if salt is False:
#             salt = urandom(32)
#         if encode:
#             salt = b64encode(salt)
#         return "$w$%s$%s$%s" % (
#             self._strength,
#             salt,
#             self._hash_multi(salt + password, self._strength)
#         )
# 
#     def check(self, attempt, h):
#         bits = h.split("$")
#         try:
#             if self._hash_multi(bits[3] + attempt, float(bits[2])) != bits[4]:
#                 raise HashMismatch()
#         except IndexError:
#             raise HashMismatch()
# 
#     def _hash_multi(self, string, strength):
#         for i in range(int(math.pow(2, strength))):
#             string = b2a_hex(whirlpool.hash(string))
#         return string


import copy
import json
import re
from datetime import datetime, time, date
from wire.utils import autoinc
from wire.utils import Hasher
                self.threads.append(t)
            except ThreadError:
                t.delete(recipient=self.user)

    def unread_count(self, thread=False):
        r = self.redis
        count = 0
        for thread in r.lrange('user:%s:threads' % self.user.key, 0, -1):
            t = Thread(redis=self.redis, user=self.user)
            count += t.get_unread_count(key=thread)
        return count


class Message:
    def __init__(self, redis, key=False, user=False):
        self.id = ""
        self.redis = redis
        self.key = key
        self.thread = False
        self.data = {}
        self.user = user
        self.recipient_usernames = []
        self.recipients = False
        self.date = str(datetime.now())
        self.status = False
        if key:
            self.load()

    def get_key(self):
        if not self.key:

# Path: wire/utils.py
# def autoinc(redis, key):
#     key = "_incs:%s" % key
#     if not redis.exists(key):
#         redis.set(key, 0)
# 
#     return redis.incr(key)
# 
# Path: wire/utils.py
# class Hasher:
#     def __init__(self, strength=16):
#         self._strength = strength
# 
#     def hash(self, password, salt=False, encode=True):
#         if salt is False:
#             salt = urandom(32)
#         if encode:
#             salt = b64encode(salt)
#         return "$w$%s$%s$%s" % (
#             self._strength,
#             salt,
#             self._hash_multi(salt + password, self._strength)
#         )
# 
#     def check(self, attempt, h):
#         bits = h.split("$")
#         try:
#             if self._hash_multi(bits[3] + attempt, float(bits[2])) != bits[4]:
#                 raise HashMismatch()
#         except IndexError:
#             raise HashMismatch()
# 
#     def _hash_multi(self, string, strength):
#         for i in range(int(math.pow(2, strength))):
#             string = b2a_hex(whirlpool.hash(string))
#         return string


# Path: wire/models.py
import copy
import json
import re
from datetime import datetime, time, date
from wire.utils import autoinc
from wire.utils import Hasher

                self.threads.append(t)
            except ThreadError:
                t.delete(recipient=self.user)

    def unread_count(self, thread=False):
        r = self.redis
        count = 0
        for thread in r.lrange('user:%s:threads' % self.user.key, 0, -1):
            t = Thread(redis=self.redis, user=self.user)
            count += t.get_unread_count(key=thread)
        return count


class Message:
    def __init__(self, redis, key=False, user=False):
        self.id = ""
        self.redis = redis
        self.key = key
        self.thread = False
        self.data = {}
        self.user = user
        self.recipient_usernames = []
        self.recipients = False
        self.date = str(datetime.now())
        self.status = False
        if key:
            self.load()

    def get_key(self):
        if not self.key:

            self.key = autoinc(self.redis, 'message')