The objective of this project is to use regular expressions to check and remove unwanted input ensuring that data conforms to security-related requirements.
Here are some steps to get started:
- Download or copy the Code.py file
- Create a text or csv file anywhere on your pc and name it
- In the file open() function (Line 4) provide the location of that text file you've created in step 1
- Paste in samples (you can use the sample inputs provided here)
- Run the code!
Here are all the valid input requirements:
- Student: 9 digits. acceptable formats: 000000000, 000 000 000
- Password: a-z, A-Z, 0-9, ascii printable special characters, minimum 12 characters
- Username: a-z, A-Z, 0-9, minimum 3 characters, maximum 20 characters
- Email: username@domain.TLD, username, domain and TLD will conform to the rules above for a “username” field. There will only be one TLD (i.e. no multiples like domain.co.uk)
- Previous: Confirm that this data field is identical to the previous line’s data field (excluding whitespace)
- Phone: A North American phone number. Possible formats: 1234567890, 123.456.7890, 123-456-7890, (123) 456-7890
- Postal: A Canadian postal code. Possible formats: A0A0A0, A0A 0A0
- Address: A string field containing a-z, A-Z, 0-9, periods and dashes.
- Binary: A single binary string, must contain only 1s and 0s with no breaks between digits
- Biography: A generic string field. Report “no” only if the field contains any html tags.
Here are some example inputs:
student,999999999
password,abcd1234
username,user123
email,testuser@testdomain.com
previous,testuse@testdomain.com
phone,123-456-7890
postal,M86 72Z
address,123 street blvd.
binary,11110000
bio, hello world
student,9999 9999
student, 111111111
password,123456abcdef!!
username,stevedave
previous,stevedave
phone,((416-111-1234
postal,H1R3T7
bio,Hello<script>World</script>
The output will be a simple “yes” or “no” string. Here is what the example output would look like (based on the provided input in the above section):
yes
no
yes
yes
no
yes
no
yes
yes
yes
no
yes
yes
yes
yes
no
yes
no