Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(32)  |  Call(23)  |  Derive(0)  |  Import(9)

src/d/j/django-otp-0.2.7/django_otp/plugins/otp_email/models.py   django-otp(Download)
 
from django_otp.models import Device
from django_otp.oath import totp
from django_otp.util import hex_validator, random_hex
 
    def generate_challenge(self):
        token = totp(self.bin_key)
        body = render_to_string('otp/email/token.txt', {'token': token})
 
        send_mail(settings.OTP_EMAIL_SUBJECT,
            verified = False
        else:
            verified = any(totp(self.bin_key, drift=drift) == token for drift in [0, -1])
 
        return verified

src/d/j/django-two-factor-auth-HEAD/two_factor/models.py   django-two-factor-auth(Download)
 
from django_otp import Device
from django_otp.oath import totp
from django_otp.util import hex_validator, random_hex
 
    def verify_token(self, token):
        for drift in range(-5, 1):
            if totp(self.bin_key, drift=drift) == token:
                return True
        return False
    def generate_challenge(self):
        """
        Sends the current TOTP token to `self.number` using `self.method`.
        """
        token = '%06d' % totp(self.bin_key)

src/d/j/django-two-factor-auth-0.5.0/two_factor/models.py   django-two-factor-auth(Download)
 
from django_otp import Device
from django_otp.oath import totp
from django_otp.util import hex_validator, random_hex
 
    def verify_token(self, token):
        for drift in range(-5, 1):
            if totp(self.bin_key, drift=drift) == token:
                return True
        return False
    def generate_challenge(self):
        """
        Sends the current TOTP token to `self.number` using `self.method`.
        """
        token = '%06d' % totp(self.bin_key)

src/d/j/django-otp-twilio-0.2.0/otp_twilio/models.py   django-otp-twilio(Download)
 
from django_otp.models import Device
from django_otp.oath import totp
from django_otp.util import random_hex, hex_validator
 
        :raises: Exception if delivery fails.
        """
        token = '{0:06}'.format(totp(self.bin_key))
 
        # Special number for test cases
            return False
        else:
            return any(totp(self.bin_key, drift=drift) == token for drift in [0, -1])
 

src/d/j/django-two-factor-auth-HEAD/two_factor/forms.py   django-two-factor-auth(Download)
 
from django_otp.forms import OTPAuthenticationFormMixin
from django_otp.oath import totp
from django_otp.plugins.otp_totp.models import TOTPDevice
try:
        for t0 in t0s:
            for offset in range(-self.tolerance, self.tolerance):
                if totp(key, self.step, t0, self.digits, self.drift + offset) == token:
                    self.drift = offset
                    self.metadata['valid_t0'] = int(time()) - t0

src/d/j/django-two-factor-auth-0.5.0/two_factor/forms.py   django-two-factor-auth(Download)
from django.utils.translation import ugettext_lazy as _
from django_otp.forms import OTPAuthenticationFormMixin
from django_otp.oath import totp
from django_otp.plugins.otp_totp.models import TOTPDevice
 
        for t0 in t0s:
            for offset in range(-self.tolerance, self.tolerance):
                if totp(key, self.step, t0, self.digits, self.drift + offset) == token:
                    self.drift = offset
                    self.metadata['valid_t0'] = int(time()) - t0

src/i/d/identity.gentoo.org-HEAD/okupy/otp/totp/models.py   identity.gentoo.org(Download)
 
        for offset in range(-2, 3):
            if oath.totp(key, drift=offset) == token:
                return True
        return False

src/d/j/django-otp-twilio-0.2.0/otp_twilio/tests.py   django-otp-twilio(Download)
from django.db import IntegrityError
 
from django_otp.oath import totp
from django_otp.tests import TestCase
 
    def test_previous(self):
        device = self.alice.twiliosmsdevice_set.get()
        token = totp(device.bin_key, t0=30)
        ok = device.verify_token(token)
 
        self.assertTrue(ok)
 
    def test_past(self):
        device = self.alice.twiliosmsdevice_set.get()
        token = totp(device.bin_key, t0=60)
    def test_future(self):
        device = self.alice.twiliosmsdevice_set.get()
        token = totp(device.bin_key, t0=-30)
        ok = device.verify_token(token)
 

src/d/j/django-two-factor-auth-HEAD/tests/tests.py   django-two-factor-auth(Download)
 
from django_otp import DEVICE_ID_SESSION_KEY, devices_for_user
from django_otp.oath import totp
from django_otp.util import random_hex
 
                         {'__all__': ['Please enter your OTP token']})
 
        response = self._post({'token-otp_token': totp(device.bin_key),
                               'login_view-current_step': 'token'})
        self.assertRedirects(response, str(settings.LOGIN_REDIRECT_URL))
        self.assertContains(response, 'We sent you a text message')
        fake.return_value.send_sms.assert_called_with(
            device=device, token='%06d' % totp(device.bin_key))
 
        # Ask for phone challenge
        self.assertContains(response, 'We are calling your phone right now')
        fake.return_value.make_call.assert_called_with(
            device=device, token='%06d' % totp(device.bin_key))
 
        # Valid token should be accepted.
        response = self._post({'token-otp_token': totp(device.bin_key),