Skip to content

Commit

Permalink
Update SIMrw.py
Browse files Browse the repository at this point in the history
Filtering phone number for unwanted chars (Buggy)
  • Loading branch information
salopeknet committed Jun 9, 2024
1 parent fb3cc75 commit fed076a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion SIMrw.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from smartcard.Exceptions import NoReadersException, CardConnectionException

# Version information
version = "0.2.2"
version = "0.2.3"

# from https://patorjk.com/software/taag/#p=display&f=Ivrit&t=SIMrw
ascii_logo = """
Expand Down Expand Up @@ -216,6 +216,10 @@ def get_records_from_csv(file_path):
records = [(int(row[0]), row[1], row[2]) for row in csv_reader]
return records

def filter_phone(phone):
allowed_chars = set('0123456789+*#p')
return ''.join([char for char in phone if char in allowed_chars])

def reverse_digits_in_pairs(phone):
reversed_phone = ''.join([phone[i:i+2][::-1] for i in range(0, len(phone), 2)])
return reversed_phone
Expand All @@ -227,6 +231,7 @@ def new_record(index, name, phone, size):
return [0xFF] * size

name = name[:size-14]
phone = filter_phone(phone)
print(f"\rWriting record {index}... ", end='', flush=True)
if args.verbose:
print(name, phone)
Expand Down

0 comments on commit fed076a

Please sign in to comment.