예제 #1
0
    def OnButtonCheckED(self, event):
        c = 'utf8'
        dlg = str(self.inputD.GetValue())
        with open(dlg, 'rb') as EDfile:
            p = EDfile.read()
        src = str(p)
        m1 = md5.new()
        m1.update(src)
        self.Md5.SetValue(m1.hexdigest().decode(c))

        m2 = _sha.new()
        m2.update(src)
        self.sha1.SetValue(m2.hexdigest().decode(c))

        m3 = _sha256.sha224()
        m3.update(src)
        self.sha224.SetValue(m3.hexdigest().decode(c))

        m4 = _sha256.sha256()
        m4.update(src)
        self.sha256.SetValue(m4.hexdigest().decode(c))

        m5 = _sha512.sha384()
        m5.update(src)
        self.sha384.SetValue(m5.hexdigest().decode(c))

        m6 = _sha512.sha512()
        m6.update(src)
        self.sha512.SetValue(m6.hexdigest().decode(c))
예제 #2
0
def test_sha224_sanity():
    if is_cli:
        #CodePlex 16870
        AssertError(NotImplementedError, _sha256.sha224)
        AssertError(NotImplementedError, _sha256.sha224, 1234)
        return

    x = _sha256.sha224()
    AreEqual(x.block_size, 64)
    AreEqual(
        x.digest(),
        '\xd1J\x02\x8c*:+\xc9Ga\x02\xbb(\x824\xc4\x15\xa2\xb0\x1f\x82\x8e\xa6*\xc5\xb3\xe4/'
    )
    AreEqual(x.digest_size, 28)
    AreEqual(x.digest_size, x.digestsize)
    AreEqual(x.hexdigest(),
             'd14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f')
    AreEqual(x.name, "SHA224")
    x.update("abc")
    AreEqual(x.hexdigest(),
             '23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7')

    x_copy = x.copy()
    Assert(x != x_copy)
    AreEqual(x.hexdigest(), x_copy.hexdigest())
예제 #3
0
    def OnButtonCheck1(self, event):
        src = str(self.inputN.GetValue().encode('utf8'))
        m1 = md5.new()
        m1.update(src)
        self.Md5.SetValue(m1.hexdigest().decode('utf8'))

        m2 = _sha.new()
        m2.update(src)
        self.sha1.SetValue(m2.hexdigest().decode('utf8'))

        m3 = _sha256.sha224()
        m3.update(src)
        self.sha224.SetValue(m3.hexdigest().decode('utf8'))

        m4 = _sha256.sha256()
        m4.update(src)
        self.sha256.SetValue(m4.hexdigest().decode('utf8'))

        m5 = _sha512.sha384()
        m5.update(src)
        self.sha384.SetValue(m5.hexdigest().decode('utf8'))

        m6 = _sha512.sha512()
        m6.update(src)
        self.sha512.SetValue(m6.hexdigest().decode('utf8'))
 def OnButtonCheckED(self, event):
     c = 'utf8'
     dlg = str(self.inputD.GetValue())
     with open(dlg,'rb') as EDfile:
         p = EDfile.read()
     src = str(p)
     m1 = md5.new()   
     m1.update(src)
     self.Md5.SetValue(m1.hexdigest().decode(c))
     
     m2 = _sha.new()   
     m2.update(src)   
     self.sha1.SetValue(m2.hexdigest().decode(c))
     
     m3 = _sha256.sha224()
     m3.update(src)   
     self.sha224.SetValue(m3.hexdigest().decode(c))
     
     m4 = _sha256.sha256()
     m4.update(src)   
     self.sha256.SetValue(m4.hexdigest().decode(c))
     
     m5 = _sha512.sha384()
     m5.update(src) 
     self.sha384.SetValue(m5.hexdigest().decode(c))  
     
     m6 = _sha512.sha512() 
     m6.update(src)   
     self.sha512.SetValue(m6.hexdigest().decode(c))
 def OnButtonCheck1(self, event):
     src = str(self.inputN.GetValue().encode('utf8'))
     m1 = md5.new()   
     m1.update(src)
     self.Md5.SetValue(m1.hexdigest().decode('utf8'))
     
     m2 = _sha.new()   
     m2.update(src)   
     self.sha1.SetValue(m2.hexdigest().decode('utf8'))
     
     m3 = _sha256.sha224()
     m3.update(src)   
     self.sha224.SetValue(m3.hexdigest().decode('utf8'))
     
     m4 = _sha256.sha256()
     m4.update(src)   
     self.sha256.SetValue(m4.hexdigest().decode('utf8'))
     
     m5 = _sha512.sha384()
     m5.update(src) 
     self.sha384.SetValue(m5.hexdigest().decode('utf8'))  
     
     m6 = _sha512.sha512() 
     m6.update(src)   
     self.sha512.SetValue(m6.hexdigest().decode('utf8'))
예제 #6
0
 def test_sha224_sanity(self):
     x = _sha256.sha224()
     self.assertEqual(x.block_size, 64)
     self.assertEqual(x.digest(),
             '\xd1J\x02\x8c*:+\xc9Ga\x02\xbb(\x824\xc4\x15\xa2\xb0\x1f\x82\x8e\xa6*\xc5\xb3\xe4/')
     self.assertEqual(x.digest_size, 28)
     self.assertEqual(x.digest_size, x.digestsize)
     self.assertEqual(x.hexdigest(),
             'd14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f')
     self.assertEqual(x.name, "SHA224")
     x.update("abc")
     self.assertEqual(x.hexdigest(),
             '23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7')
     
     x_copy = x.copy()
     self.assertTrue(x!=x_copy)
     self.assertEqual(x.hexdigest(), x_copy.hexdigest())
예제 #7
0
def register_phone(request):

    username = request.POST.get('username', '')
    password = request.POST.get('password', '')

    if username == '' or password == '':
        return HttpResponse(status=404)

    try:
        validate_email(username)
    except ValidationError:
        data = {
            "error": 2,
            "message":
            "Invalid username format (must be a valid email address)"
        }
        return JsonResponse(data, safe=False, status=400)

    try:
        User.objects.get(email=username)
        data = {
            "error": 1,
            "message": "This mail is already used in an account"
        }
        return JsonResponse(data, safe=False, status=400)
    except ObjectDoesNotExist:
        token = sha224(uuid4().hex.encode('utf-8')).hexdigest()
        new_user = User()
        new_user.token = token
        new_user.email = username
        new_user.set_password(password)
        new_user.save()

        context = {
            'user': new_user,
            'token': token,
            'site_url': settings.SITE_URL
        }
        html_content = render_to_string(
            'email/token.html',
            context,
            context_instance=RequestContext(request))
        if send_email(new_user.email, 'NG Notifier', html_content, 'html'):
            return HttpResponse(status=200)

        return HttpResponse(status=500)
예제 #8
0
    def save(self):
        cleaned_data = super().clean()
        email = cleaned_data.get('email')

        token = sha224(uuid4().hex.encode('utf-8')).hexdigest()
        try:
            # If the user already exists, we just update its token
            user = User.objects.get(email=email)
            user.token = token
            user.save()
            return user, token
        except ObjectDoesNotExist:
            new_user = User()
            new_user.token = token
            new_user.email = email
            new_user.save()
            return new_user, token
예제 #9
0
    def test_sha224_sanity(self):
        x = _sha256.sha224()
        self.assertEqual(x.block_size, 64)
        self.assertEqual(x.digest(),
                '\xd1J\x02\x8c*:+\xc9Ga\x02\xbb(\x824\xc4\x15\xa2\xb0\x1f\x82\x8e\xa6*\xc5\xb3\xe4/')
        self.assertEqual(x.digest_size, 28)
        self.assertEqual(x.digest_size, x.digestsize)
        self.assertEqual(x.hexdigest(),
                'd14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f')
        self.assertEqual(x.name, "SHA224")
        x.update("abc")
        self.assertEqual(x.hexdigest(),
                '23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7')

        x_copy = x.copy()
        self.assertTrue(x!=x_copy)
        self.assertEqual(x.hexdigest(), x_copy.hexdigest())
예제 #10
0
def forgot_password_phone(request):

    username = request.POST.get('username', '')

    if username == '':
        return HttpResponse(status=200)

    try:
        token = sha224(uuid4().hex.encode('utf-8')).hexdigest()
        user = User.objects.get(email=username)
        user.token = token
        user.save()
        context = {'user': user, 'token': token, 'site_url': settings.SITE_URL}
        html_content = render_to_string(
            'email/forgot_password.html',
            context,
            context_instance=RequestContext(request))
        if send_email([user.email], 'NG Notifier', html_content, 'html'):
            return HttpResponse(status=200)
    except ObjectDoesNotExist:
        return HttpResponse(status=200)
예제 #11
0
파일: _sha256.py 프로젝트: 89sos98/main
def test_sha224_sanity():
    if is_cli:
        #CodePlex 16870
        AssertError(NotImplementedError, _sha256.sha224)
        AssertError(NotImplementedError, _sha256.sha224, 1234)
        return

    x = _sha256.sha224()
    AreEqual(x.block_size, 64)
    AreEqual(x.digest(),
             '\xd1J\x02\x8c*:+\xc9Ga\x02\xbb(\x824\xc4\x15\xa2\xb0\x1f\x82\x8e\xa6*\xc5\xb3\xe4/')
    AreEqual(x.digest_size, 28)
    AreEqual(x.digest_size, x.digestsize)
    AreEqual(x.hexdigest(),
             'd14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f')
    AreEqual(x.name, "SHA224")
    x.update("abc")
    AreEqual(x.hexdigest(),
             '23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7')
    
    x_copy = x.copy()
    Assert(x!=x_copy)
    AreEqual(x.hexdigest(), x_copy.hexdigest())
예제 #12
0
파일: hash.py 프로젝트: moreati/stubtool
import _hashlib

from ._util import PY2, PY33


if PY2:
    import _md5
    import _sha
    import _sha256
    import _sha512


    md5 = type(_md5.new())
    sha1 = type(_sha.new())
    sha224 = type(_sha256.sha224())
    sha256 = type(_sha256.sha256())
    sha384 = type(_sha512.sha384())
    sha512 = type(_sha512.sha512())
elif PY33:
    import _md5
    import _sha1
    import _sha256
    import _sha512


    md5 = type(_md5.md5())
    sha1 = type(_sha1.sha1())
    sha224 = type(_sha256.sha224())
    sha256 = type(_sha256.sha256())
    sha384 = type(_sha512.sha384())
예제 #13
0
def hash_text(text):
    return sha224(text.encode('utf8')).hexdigest()
예제 #14
0
 def save(self, *args, **kwargs):
     if not self.pk:
         self.session_key = sha224(uuid4().hex.encode('utf-8')).hexdigest()
     return super(DeviceSession, self).save(*args, **kwargs)