资源简介
已经在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 及 破解 补丁
相关资源
- SpringMVC文件上传与的实现.rar
- VisualStudioUninstaller vs卸载工具
- 组态王驱动开发包3.0.0.7(中文)
- 多窗口后台鼠标连点器
- 使用选择性重传协议实现UDP可靠通信
- Windows异步套接字网络编程
- VC 获得文件属性 获取文件的创建时
- 基于MVC模式的会员管理系统
- silicon lab公司的收音IC SI47XX全套开发工
- 读者写者问题(读者优先,写者优先
- MFC程序-碰撞的小球
- vc 柱形图 CBarChart
- 用vc 写的导线测量,针对刚学测绘的
- 用VC 编写的仿QQ聊天室程序源代码
- 栅栏填充算法源码(VC)
- 外点法程序
- 外罚函数程序
- 简单的房屋租赁系统
- .net网站服装销售系统(MVC)
- qt-电子点菜系统
- 推箱子及人工智能寻路C 源代码
- 自己写的航空订票系统c 版--数据结构
- 数据结构实验魔王语言
- MUSIC算法c 实现
- C 餐厅叫号系统(QT平)
- 国际象棋c 完整版
-
ob
jectARX给Auto CAD加工具条 - blowfish的vc2008工程.rar
- 画图程序MFC/VC/VC CRectTracker 串行化
- MFC网络编程实例
评论
共有 条评论