Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class infinitelist(object):
- #allows a list to be accessed infinitely, where indexes beyond it's length are reduced to match an index.
- def __init__(self, lst):
- self.lst = lst
- def __repr__(self):
- return str(self.lst)
- def __len__(self):
- return len(self.lst)
- def __getitem__(self, i):
- if i == len(self.lst):
- return self.lst[i%len(self.lst)]
- elif i > len(self.lst)-1:
- return self.lst[i%len(self.lst)-1]
- else:
- return self.lst[i]
- def num_hash(i):
- chars = ['a', 'b', 'c', 'd',
- 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
- 'n', 'o', 'p', 'q', 'r', 's',
- 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2',
- '3', '4', '5', '6', '7', '8', '9']
- selection = infinitelist([x+y for x in chars for y in chars])
- hashed = ''
- while len(hashed) < 16:
- if i % 2 == 0:
- hashed += selection[i]
- i *= 4
- elif len(hashed) % 2 == 0:
- hashed += selection[i+4]
- i *= 3
- else:
- hashed += selection[i+1]
- i += 8
- return hashed
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement