QR-kod
Profilbild för Ssn Generator Coding

Ssn Generator Coding

United States

# SSNPad.py - creates a SSN scratch pad. This is used to map one SSN value to # a random replacement value. Useful to protect a SSN number while preserving # the format of the data. Reasonably secure if the scratch pad is kept secure. # This script creates a text file with the following structure: # XXXXXXXXX|YYYYYYYYY # where XXXXXXXXX is the source SSN and # YYYYYYYYY is a psuedo(semi)-random alternate SSN # Sample: # SSN numbers are composed of three parts: # AAA-GG-IIII # AAA = The Area (used to map to a state, doesn't anymore) # GG = Group 01-99 # IIII a zero padded number between 0001-9999 # This process takes a specific source Area and Group (i.e. 123-45) and maps it # to a randomly chosen different replacement Area and Group (i.e. 763-22) and # then generates a random replacement ID for each source ID. # A sample of the output: # 001010001|686075132 # 001010002|686074919 # 001010003|686077114 # 001010004|686078786 import random from itertools import product f = open("SSNList.txt",'w+') master_groups = list(product(range(1, 899 + 1), range(1, 99+1))) area_groups = list(master_groups) for (area, group) in master_groups: area_group = random.choice(area_groups) id_list = range(1, 9999 + 1) for n in range(1, 9999 + 1): leftSSN = "{0:0>3}{1:0>2}{2:0>4}".format(area, group, n) random_id = random.choice(id_list) rightSSN = '{0:0>3}{1:0>2}{2:0>4}'.format( area_group[0], area_group[1], random_id) id_list.remove(random_id) f.write('{0}|{1}n'.format(leftSSN,rightSSN)) area_groups.remove(area_group) f.close()