• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > python实现计算资源图标crc值的方法

python实现计算资源图标crc值的方法

作者:shichen2014 字体:[增加 减小] 来源:互联网

shichen2014 通过本文主要向大家介绍了python crc16,python crc32,python crc校验,crc电缆清洗剂,crc 出版社等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

本文实例讲述了python实现计算资源图标crc值的方法,分享给大家供大家参考。具体方法如下:

实现该功能的关键在于解析资源信息,找到icon的数据,然后计算这些数据的crc

具体实现代码如下:

  def _get_iconcrc(self, file_path): 
    """ 
    Generates the crc32 hash of the icon of the file. 
    @return: str, the str value of the file's icon 
    """ 
    iconData = "" 
 
    mype = pefile.PE(file_path) 
    if hasattr(mype, "DIRECTORY_ENTRY_RESOURCE"): 
      resIcons = filter(lambda x: x.id==pefile.RESOURCE_TYPE['RT_ICON'], mype.DIRECTORY_ENTRY_RESOURCE.entries) 
      if len(resIcons)>0: 
        resIcons = resIcons[0] 
        if hasattr(resIcons, "directory"): 
          for resId in resIcons.directory.entries: 
            if hasattr(resId, 'directory'): 
              for resLang in resId.directory.entries: 
                iconData += mype.get_data(resLang.data.struct.OffsetToData, resLang.data.struct.Size) 
     
    if not iconData: 
      print "not iconData" 
      return None 
    else: 
      return self._crc32(iconData) 
</div>

希望本文所述对大家的Python程序设计有所帮助。

</div>

您可能想查找下面的文章:

  • python实现计算资源图标crc值的方法
  • python实现计算资源图标crc值的方法

相关文章

  • python静态方法实例
  • 在Python的Django框架中使用通用视图的方法
  • python开发环境PyScripter中文乱码问题解决方案
  • python通过BF算法实现关键词匹配的方法
  • python网络编程学习笔记(四):域名系统
  • 详解python如何调用C/C++底层库与互相传值
  • Python制作爬虫采集小说
  • 在CentOS上配置Nginx+Gunicorn+Python+Flask环境的教程
  • Python在图片中添加文字的两种方法
  • python迭代器与生成器详解

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • Python去除列表中重复元素的方法
    • Python牛刀小试密码爆破
    • 详解Python的collections模块中的deque双端队列结构
    • python列出目录下指定文件与子目录的方法
    • python错误:AttributeError: 'module' object has no attribute 'setdefaultencoding'问题的解决方法
    • 全面了解Python的getattr(),setattr(),delattr(),hasattr()
    • python使用内存zipfile对象在内存中打包文件示例
    • 基于Python实现的百度贴吧网络爬虫实例
    • Python的Flask框架中web表单的教程
    • 详解Python中列表和元祖的使用方法

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有