This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.cache import cache | |
from django.http import HttpResponseForbidden | |
from functools import wraps | |
from django.utils.decorators import available_attrs | |
def ratelimit(limit=10,length=86400): | |
""" The length is in seconds and defaults to a day""" | |
def decorator(func): | |
def inner(request, *args, **kwargs): | |
ip_hash = str(hash(request.META['REMOTE_ADDR'])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Taken from https://github.com/weavejester/crypto-equality/blob/master/src/crypto/equality.clj | |
(ns crypto.equality | |
"Securely test sequences of data for equality.") | |
(defn eq? | |
"Test whether two sequences of characters or bytes are equal in a way that | |
protects against timing attacks. Note that this does not prevent an attacker | |
from discovering the *length* of the data being compared." | |
[a b] |