资源简介
已经在windows下编译好的32位Botan-2.10.0, 可以直接使用
Botan是一个功能齐全的加解密库,详细用法可以查看官方网站
代码片段和文件信息
#!/usr/bin/python
“““
Python wrapper of the botan crypto library
https://botan.randombit.net
(C) 201520172018 Jack Lloyd
(C) 2015 Uri Blumenthal (extensions and patches)
Botan is released under the Simplified BSD License (see license.txt)
This module uses the ctypes module and is usable by programs running
under at least CPython 2.7 CPython 3.x and PyPy
It uses botan‘s ffi module which exposes a C API. This version of the
module requires FFI API version 20180713 which was introduced in
Botan 2.8
“““
from ctypes import CDLL POINTER byref create_string_buffer \
c_void_p c_size_t c_uint8 c_uint32 c_uint64 c_int c_char c_char_p
from sys import version_info
from time import strptime mktime
from binascii import hexlify
from datetime import datetime
BOTAN_FFI_VERSION = 20180713
#
# base exception for all exceptions raised from this module
#
class BotanException(Exception):
def __init__(self message rc=0):
self.__rc = rc
if rc == 0:
super(BotanException self).__init__(message)
else:
descr = botan.botan_error_description(rc).decode(‘ascii‘)
super(BotanException self).__init__(“%s: %d (%s)“ % (message rc descr))
def error_code(self):
return self.__rc
#
# Module initialization
#
def load_botan_dll(expected_version):
possible_dll_names = [‘libbotan-2.dylib‘ ‘libbotan-2.so‘] + \
[‘libbotan-2.so.%d‘ % (v) for v in reversed(range(8 16))]
for dll_name in possible_dll_names:
try:
dll = CDLL(dll_name)
dll.botan_ffi_supports_api.argtypes = [c_uint32]
dll.botan_ffi_supports_api.restype = c_int
if dll.botan_ffi_supports_api(expected_version) == 0:
return dll
except OSError:
pass
return None
botan = load_botan_dll(BOTAN_FFI_VERSION) # pylint: disable=invalid-name
if botan is None:
raise BotanException(“Could not find a usable Botan shared object library“)
#
# ctypes function prototypes
#
def errcheck_for(fn_name):
def errcheck(rc _func _args):
# No idea what to do if return value isn‘t an int just return it
if not isinstance(rc int):
return rc
if rc >= 0:
return rc
if rc == -10: # insufficient buffer space pass up to caller
return rc
raise BotanException(‘%s failed‘ % (fn_name) rc)
return errcheck
botan.botan_version_string.argtypes = []
botan.botan_version_string.restype = c_char_p
botan.botan_error_description.argtypes = [c_int]
botan.botan_error_description.restype = c_char_p
# RNG
botan.botan_rng_init.argtypes = [c_void_p c_char_p]
botan.botan_rng_init.errcheck = errcheck_for(‘botan_rng_init‘)
botan.botan_rng_destroy.argtypes = [c_void_p]
botan.botan_rng_destroy.errcheck = errcheck_for(‘botan_rng_destroy‘)
botan.botan_rng_reseed.argtypes = [c_void_p c_size_t]
botan.botan_rng_reseed.errcheck = errcheck_for(‘bota
- 上一篇:游戏策划之数值策划入门文档
- 下一篇:getdata 2.22 及 破解 补丁
相关资源
- 图像处理所有基本源代码复原,编码
- 时间差分法帧间差分法opencv和vc代码实
- 超多木马及病毒的源代码!!(VC及汇编
- UML图设计模式、三层架构、MVC.EAP
- 基于VS2008的可视化时钟
- High Efficiency Video Coding (Hevc) Algori
- 简易抽奖软件含源码
- 串口调试助手VC源码
- opengl实现太阳系动态模型,地球,月
- springmvc 增删改查
- [epub] 像程序员一样思考修订版
- wave VCD Viewer波形查看工具(GTKwave)独
- glfw-3.2.1源码(需要自行编译)
- 免费的图形控件VC
- 广工信工图像处理作业
- VMware vSphere P2V操作文档 图文版VMware
- H.264 SVC FSVM测试模型
- vc opencv 条形码 识别
- opengl 实现的机器人行走
- 周报提交系统带登陆.NET MVC
- maven多模块项目+springMVC+mybatis配置
- 变网格步长声波方程有限差分数值模
- 饭店餐饮收费信息系统
- 图书管理ssm框架整合篇
- GMM模型实现
- 二相步进电机细分驱动源码 STM32F103
- Vclskin 破解版
- Read_Ionex.rar
- 模拟指针式和电子式时钟
- QT实现图书馆管理系统
评论
共有 条评论