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

All Samples(6)  |  Call(5)  |  Derive(0)  |  Import(1)

src/b/l/BlueCop-XBMC-Plugins-HEAD/script.module.cryptopy/lib/crypto/keyedHash/hmacHash_test.py   BlueCop-XBMC-Plugins(Download)
 
import unittest
from crypto.keyedHash.hmacHash import HMAC, HMAC_SHA1
from crypto.hash.sha1Hash      import SHA1
from crypto.hash.md5Hash       import MD5
        ko = ''.join([chr(0x5C) for i in range(64)])
        h = SHA1()
        keyedHashAlg = HMAC(SHA1,key='')
        assert ( keyedHashAlg('') == h(ko+h(ki)) ), 'Null key, Null data test'
        assert ( keyedHashAlg('a') == h(ko+h(ki+'a')) ), 'Null key, a data test'
        ko = ''.join([chr(0x5C) for i in range(64)])
        h = MD5()
        keyedHashAlg = HMAC(MD5,key='')
        assert ( keyedHashAlg('') == h(ko+h(ki)) ), 'Null key, Null data test'
        assert ( keyedHashAlg('a') == h(ko+h(ki+'a')) ), 'Null key, a data test'
        ko = chr(ord(ko[0])^0xFF)+ ko[1:]
        h = SHA1()
        keyedHashAlg = HMAC(SHA1,chr(0xff))
        assert ( keyedHashAlg('') == h(ko+h(ki)) ), 'one byte key, Null data test'
        assert ( keyedHashAlg('a') == h(ko+h(ki+'a')) ), 'one byte key, a data test'
    def testRFC2104_1(self):
        """ RFC2104 test 1 and various calling methods """
        key          = chr(0x0b)*20
        keyedHashAlg = HMAC(SHA1,key)
        data         = "Hi There"