Created
September 27, 2011 20:29
-
-
Save cjameshuff/1246142 to your computer and use it in GitHub Desktop.
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 lpcrc(fw) | |
# fix CRC (thanks to Roel Verdult for the lpcrc utility this is based on) | |
blocks = fw.unpack('V7') # read 7 little endian 32-bit integers | |
crc = (~(blocks.inject(0) {|crc, block| (crc + block) & 0xFFFFFFFF}) + 1) & 0xFFFFFFFF | |
fw[7*4, 4] = [crc].pack('V') | |
fw | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment