示例#1
0
def GenerateCheckdigit(basename):
   alg = crc_algorithms.Crc(width = 4, poly = 64+2+1, reflect_in=False,
                            xor_in=0, reflect_out=False, xor_out=0)
   crc = alg.bit_by_bit(basename) & ((1<<4)-1) # Calc CRC and limit to 15
   letters="ACEFGHJKLMPRTWXN"
   crcletter=letters[crc]
   return crcletter
示例#2
0
def crc_wrap(init, data, hash_width):

    data_int = 0
    for i in range(len(data)):
        data_int |= (data[i]) << (i) * 8
    data = int.to_bytes(data_int, len(data), byteorder='little')

    crc = ca.Crc(width=16,
                 poly=0x8d95,
                 reflect_in=False,
                 xor_in=init,
                 reflect_out=False,
                 xor_out=0x0)
    return (crc.bit_by_bit(data) % (2**hash_width))
示例#3
0
文件: steam_grid.py 项目: jzerbe/Ice
 def filename_for_shortcut(self,name,target):
   """
   Calculates the filename for a given shortcut. This filename is a 64bit
   integer, where the first 32bits are a CRC32 based off of the name and
   target (with the added condition that the first bit is always high), and
   the last 32bits are 0x02000000.
   """
   # This will seem really strange (where I got all of these values), but I
   # got the xor_in and xor_out from disassembling the steamui library for 
   # OSX. The reflect_in, reflect_out, and poly I figured out via trial and
   # error.
   algorithm = crc_algorithms.Crc(width = 32, poly = 0x04C11DB7, reflect_in = True, xor_in = 0xffffffff, reflect_out = True, xor_out = 0xffffffff)
   input_string = ''.join([target,name])
   top_32 = algorithm.bit_by_bit(input_string) | 0x80000000
   full_64 = (top_32 << 32) | 0x02000000
   return str(full_64)
示例#4
0
def generate_appid_for_nonsteam_game(name, target):
    """
        (Thanks to github.com/scottrice)

        Generates the app ID for a Non-Steam game.
        This ID is a 64bit integer, where the first 32bits are
        a CRC32 based off of the name and target (with the added
        condition that the first bit is always high), and
        the last 32bits are 0x02000000.

        Paramteters:
            name - Game name
            target - Exe file location

        Returns:
            The app ID as a string
    """

    algorithm = crc_algorithms.Crc(width = 32, poly = 0x04C11DB7, reflect_in = True, xor_in = 0xffffffff, reflect_out = True, xor_out = 0xffffffff)
    input_string = ''.join([target,name])
    top_32 = algorithm.bit_by_bit(input_string) | 0x80000000
    full_64 = (top_32 << 32) | 0x02000000
    return str(full_64)