def name_for_nsec3_next(self, nsec_name): '''Convert the next field of an NSEC3 RR to a DNS name.''' next_name = self.rrsets[nsec_name].rrset[0].next next_name_txt = base32.b32encode(next_name) origin = dns.name.Name(nsec_name.labels[1:]) return dns.name.from_text(next_name_txt, origin)
def get_digest_name_for_nsec3(self, name, origin, salt, alg, iterations): '''Return the DNS name corresponding to the name, origin, and NSEC3 hash parameters provided.''' val = name.canonicalize().to_wire() digest = crypto.get_digest_for_nsec3(val, salt, alg, iterations) if digest is None: return None else: return dns.name.from_text(base32.b32encode(digest), origin)
#!/usr/bin/env python # -*- coding: ascii -*- import base32 import binascii if __name__ == '__main__': bin=binascii.unhexlify('6bc569718546721b1035c909ab864cbc') ascii=base32.b32encode(bin) print ascii
import binascii,base32 longest=0 long_a='' long_b='' with open('/home/rob/findmatchmd5.txt') as f: lines=f.read().splitlines() lines = [base32.b32encode(binascii.a2b_hex(line)) for line in lines] for n in range(0,len(lines)-1): for i in reversed(list(range(longest, 32))): if (lines[n][0:i]==lines[n+1][0:i]): longest=i long_a=lines[n] long_b=lines[n+1] if longest==5: print(longest, long_a, long_b) break #print longest, long_a, long_b
#!/usr/bin/env python # -*- coding: ascii -*- import hashlib import base32 """ Open a file by name, find the SHA2 value and Base32 that to produce the output. This is just a fragile prototype. """ print base32.b32encode(hashlib.sha256(open('filesha2byarg.py', 'rb').read()).digest())
import base32 import binascii with open('/home/rob/findmatchmd5.txt') as f: lines=f.read().splitlines() for line in lines: binline = binascii.a2b_hex(line) encoded = base32.b32encode(binline) decoded = base32.b32decode(encoded) print line,encoded,decoded.encode('hex')