Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
27 lines (19 sloc)
643 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def __str2int(value): | |
| try: | |
| val = int(value) | |
| if isinstance(val, int): | |
| return val | |
| else: | |
| return 0 | |
| except ValueError: | |
| return 0 | |
| def __calc_checksum(value): | |
| steps = 0 | |
| for num in value: | |
| steps += __str2int(num) | |
| return steps | |
| if __name__ == '__main__': | |
| machine_id = input("Please enter Machine ID / Model Name. :") | |
| serial_no = input("Please enter Serial No. :") | |
| checksum = 147 - __calc_checksum(machine_id) - __calc_checksum(serial_no) | |
| print("BIOS Checksum = Hex :", hex(checksum)[2:], ", Ascii :", chr(checksum)) |