Beispiel #1
0
    def test_all(self):
        strvec = [
            '',
            'The quick brown fox jumps over the lazy dog',
            'The quick brown fox jumps over the lazy cog',
            'Nobody inspects the spammish repetition'
        ]

        target = [
            '9c1185a5c5e9fc54612808977ee8f548b2258d31',
            '37f332f68db77bd9d7edd4969571ad671cf9dd3b',
            '132072df690933835eb8b6ad0b77e7b6f14acad7',
            'cc4a5ce1b3df48aec5d22d1f16b894a0b894eccc'
        ]

        hash160target = [
            'b472a266d0bd89c13706a4132ccfb16f7c3b9fcb',
            '0e3397b4abc7a382b3ea2365883c3c7ca5f07600',
            '53e0dacac5249e46114f65cb1f30d156b14e0bdc',
            '1c9b7b48049a8f98699bca22a5856c5ef571cd68'
        ]

        for i, s in enumerate(strvec):
            digest = ripemd.RIPEMD160(s).digest()
            hash160digest = ripemd.RIPEMD160(bin_sha256(s)).digest()
            self.assertEqual(digest.encode('hex'), target[i])
            self.assertEqual(hash160digest.encode('hex'), hash160target[i])
            self.assertEqual(bin_hash160(s).encode('hex'), hash160target[i])
            self.assertEqual(hash160(s), hash160target[i])
Beispiel #2
0
    target = ['']*4

    target[0] = '9c1185a5c5e9fc54612808977ee8f548b2258d31'
    target[1] = '37f332f68db77bd9d7edd4969571ad671cf9dd3b'
    target[2] = '132072df690933835eb8b6ad0b77e7b6f14acad7'
    target[3] = 'cc4a5ce1b3df48aec5d22d1f16b894a0b894eccc'

    hash160target = ['']*4

    hash160target[0] = 'b472a266d0bd89c13706a4132ccfb16f7c3b9fcb'
    hash160target[1] = '0e3397b4abc7a382b3ea2365883c3c7ca5f07600'
    hash160target[2] = '53e0dacac5249e46114f65cb1f30d156b14e0bdc'
    hash160target[3] = '1c9b7b48049a8f98699bca22a5856c5ef571cd68'

    success = True
    try:
        for i in range(len(strvec)):
            digest = ripemd.RIPEMD160(strvec[i]).digest()
            hash160digest = ripemd.RIPEMD160(bin_sha256(strvec[i])).digest()
            assert digest.encode('hex') == target[i]
            assert hash160digest.encode('hex') == hash160target[i]
            assert bin_hash160(strvec[i]).encode('hex') == hash160target[i]
            assert hash160(strvec[i]) == hash160target[i]
    except AssertionError:
        print 'ripemd160 test failed.'
        success = False
    
    if success:
        print "ripemd160 test successful."