def validate(self):
with open(self.filename, "<STR_LIT:rb>") as f:<EOL><INDENT>text = f.read()<EOL><DEDENT>start_last_line = text.rfind(b"<STR_LIT:\n>", <NUM_LIT:0>, -<NUM_LIT:1>)<EOL>if start_last_line == -<NUM_LIT:1>:<EOL><INDENT>return False<EOL><DEDENT>original_text = text[:start_last_line+<NUM_LIT:1>]<EOL>last_line = text[start_last_line+<NUM_LIT:1>:]<EOL>expected_hash = hashlib.sha1(original_text).hexdigest().encode('<STR_LIT:utf8>')<EOL>match = re.search(b"<STR_LIT>", last_line)<EOL>if not match:<EOL><INDENT>return False<EOL><DEDENT>actual_hash = match.group(<NUM_LIT:0>)<EOL>return actual_hash == expected_hash<EOL>
Check if the file still has its original contents.

Returns True if the file is unchanged, False if it has been tampered
with.