hashlib++ - a simple hash library for C++
Copyright (c) 2007-2010 Benjamin Gr�delbach
About this document:
This document explains the basics of the hashlib++ library.
You should read this stuff if you are new to hashlib++.
Apr 2010
-------------------------------------------------------------------------------
Table of contents:
0) About hashlib++
1) Current version / What's new?
2) Supported hash functions
3) Building hashlib++
4) The structure of hashlib++
5) The library's files
6) Using hashlib++
7) Supported operation systems
8) License
9) Feedback, Questions, Contact
10) Third party agreements
-------------------------------------------------------------------------------
0) About hashlib++?
hashlib++ is a simple and very easy to use library to create a cryptographic
checksum called "hash". hashlib++ is written in plain C++ and should work with
every compiler and platform. hashlib++ is released under the BSD-license (see
section 8) and therefore free software.
-------------------------------------------------------------------------------
1) Current version / What's new?
The current stable version of hashlib++ is: 0.3.2
Improvements for hashlib++ version 0.3.2:
* BUGFIX on 64-Bit Systems: hashlib++ runs finally stable there.
* Added test functions to test the hash-implementations on the target system
at run time.
* Renamed hashlib++ internal typedefs in order to fix typedef conflicts
with OpenSSL and others.
* Re-Added the Makefile to build hashlib++ as static library on UNIX-
like systems.
-------------------------------------------------------------------------------
2) Supported hash functions
By now hashlib++ supports the following functions:
* MD5 Message-Digest algorithm 5
* SHA1 Secure Hash Algorithm 1
* SHA2-Family Secure Hash Algorithm 256, 384 and 512
-------------------------------------------------------------------------------
3) Building hashlib++
To use hashlib++ you have one of the following options:
3.1) Using hashlib++ as a source code library
hashlib++ comes as a source code library. You can add the
files (or only those you need) to your project as you like and
compile it. That's all!
3.2) Using hashlib++ as static library
Another option is to to use hashlib++ as a static library and integrate this
library into your build process.
If you are using a UNIX-like operating system (like Linux, FreeBSD ...)
you can use the Makefile in the src-directory to build hashlib++
as a static library.
Before you start, you should jump into the Makefile an edit some
settings to meet your needs:
While INCLUDE_PATH is the path where the header files will be
installed, LIB_PATH is the path where the static library will
be installed.
* Type 'make' to build the library.
* Type 'make install' to build and install the library.
* Type 'make clean' to clean the object files.
(On FreeBSD you need gmake)
The name of the lib will be libhl++.a so you have to link
against hl++. For example like
g++ h.cpp -I/usr/include/hashlib++/ -lhl++
If you are using a Windows operating system, you can create
a new blank project (for example in Visual Studio), add the
hashlib++ source files and compile everything as library.
Of cause you can also use the Unix-Makefile within Cygwin.
-------------------------------------------------------------------------------
4) The structure of hashlib++
hashlib++ provides so called "wrappers" for each supported hash function which
simplify the creation of the relevant hash. Instead of implementing the full
algorithm for the hash function you only need to instantiate a desired wrapper
and call a member function like getHashFromString() or getHashFromFile().
The wrappers:
* md5wrapper for MD5 in hl_md5wrapper.h
* sha1wrapper for SHA1 in hl_sha1wrapper.h
* sha256wrapper for SHA256 in hl_sha256wrapper.h
* sha384wrapper for SHA384 in hl_sha384wrapper.h
* sha512wrapper for SHA512 in hl_sha512wrapper.h
-------------------------------------------------------------------------------
5) The library's files
The library consist of the the following files:
* Makefile
The Unix Makefile to build hashlib++ as
static library on UNIX-like systems.
* hashlibpp.h
Basic include-file. Include this file to
access hashlib++.
* hl_exception.h
Exception-Class for error-handling.
* hl_hashwrapper.h
This is a base class of all wrappers.
* hl_wrapperfactory.h
This is a simple factory for creating wrappers
* hl_md5.h and hl_md5.cpp
These two files implement the MD5 algorithm.
* hl_md5wrapper.h and hl_md5wrapper.cpp
These files represents the MD5 wrapper.
* hl_sha1.h and hl_sha1.cpp
These two files implement the SHA1 algorithm.
* hl_sha1wrapper.h and hl_sha1wrapper.cpp
These files represents the SHA1 wrapper.
* hl_sha256.h and hl_sha256.cpp
These two files implement the SHA256 algorithm.
* hl_sha256wrapper.h and hl_sha256wrapper.cpp
These files represents the SHA256 wrapper.
* hl_sha2ext.h and hl_sha2ext.cpp
This is the implementation of SHA384 and SHA512
algorithm.
* hl_2mac.h
Contains some macros used in the SHA384 and SHA512
implementation.
* hl_sha384wrapper.h and hl_sha384wrapper.cpp
The wrapper class for SHA384.
* hl_sha512wrapper.h and hl_sha512wrapper.cpp
The wrapper class for SHA512.
* hl_types.h
Contains internal typedefs.
-------------------------------------------------------------------------------
6) Using hashlib++
Using hashlib++ is very easy. First you have to include the hashlib++ header file :
#include <hashlibpp.h>
Now you are ready to create a wrapper object, for example a MD5-Wrapper:
hashwrapper *myWrapper = new md5wrapper();
Another way to create wrappers is to use the wrapperfactory:
wrapperfactory factory;
hashwrapper *foo = factory.create("md5");
hashwrapper *bar = factory.create(HL_MD5);
If you like you can perform a test to check if the wrapper works fine
on the target system, by calling the test function:
try
{
myWrapper->test();
}
catch(hlException &e)
{
//your error handling here
}
If everything worked fine you can create a hash based on a string or a file:
try
{
std::cout << myWrapper->getHashFromString("Hello world") << std::endl;
std::cout << myWrapper->getHashFromFile("/etc/motd") << std::endl;
}
catch(hlException &e)
{
//your error handling here
}
Don't forget to clean up (or create the wrapper on the stack)
delete myWrapper;
myWrapper = NULL;
More examples can be found in the "tools"-directory:
* tools/hello.cpp
Prints "Hello World" as MD5 to stdout.
* tools/h.cpp
A commandline tool to create checksums.
* tools/libtest.cpp
Performs a Test for every supported hash function.
-------------------------------------------------------------------------------
7) Supported operation systems
hashlib++ was written in standard C++, so it is platform independent and
should work with every C++ compiler. It was tested on the following systems
which are official supported:
FreeBSD 6.2 with g++ 3.4.6 and 4.1.3
Microsoft Windows XP with Microsoft Visual C++ 2005 Express Edition
Gnu/Linux 2.6 with g++ 3.4.6 and 4.3.4
-------------------------------------------------------------------------------
8) License
hashlib++ - a simple hash library for C++
Copyright (c) 2007-2011 Benjamin Gr�delbach
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1) Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2) Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distributi
没有合适的资源?快使用搜索试试~ 我知道了~
hashlib++一个简单易用的用来生成 checksum 算法,C++源代码
共91个文件
svn-base:39个
cpp:18个
h:15个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 117 浏览量
2024-03-22
22:02:31
上传
评论
收藏 177KB ZIP 举报
温馨提示
hashlib++ 是一个简单易用的库,用于创建加密 在 C++ 中称为“哈希”的校验和。hashlib++ 是用普通的 C++ 编写的,应该可以与 每个编译器和平台。该库在 BSD 许可下发布 因此是自由软件。 hashlib++ 允许您仅使用一个哈希(例如 MD5 或 SHA1)创建一个哈希 单个方法调用。因此,如果您想创建基于哈希的哈希 快速地对文件或字符串感兴趣。试一试吧。
资源推荐
资源详情
资源评论
收起资源包目录
hashlibpp_0_3_4_C++.zip (91个子文件)
hashlib2_C++
trunk
tools
libtest.cpp 3KB
hello.cpp 2KB
.svn
prop-base
text-base
h.cpp.svn-base 6KB
libtest.cpp.svn-base 3KB
hello.cpp.svn-base 2KB
props
tmp
prop-base
text-base
props
entries 685B
all-wcprops 400B
h.cpp 6KB
doc
FAQ.TXT 1KB
examples
sha1example.cpp 349B
sha384example.cpp 386B
sha256example.cpp 351B
.svn
prop-base
text-base
sha512example.cpp.svn-base 351B
sha256example.cpp.svn-base 351B
sha384example.cpp.svn-base 386B
md5example.cpp.svn-base 527B
sha1example.cpp.svn-base 349B
props
tmp
prop-base
text-base
props
entries 1014B
all-wcprops 728B
sha512example.cpp 351B
md5example.cpp 527B
uml
uml.dia 75KB
.svn
prop-base
text-base
uml.dia.svn-base 75KB
props
tmp
prop-base
text-base
props
entries 390B
all-wcprops 192B
Doxyfile 10KB
.svn
prop-base
text-base
FAQ.TXT.svn-base 1KB
LICENSE.TXT.svn-base 1KB
Doxyfile.svn-base 10KB
README.TXT.svn-base 13KB
props
tmp
prop-base
text-base
props
entries 861B
all-wcprops 500B
LICENSE.TXT 1KB
README.TXT 13KB
src
hl_sha512wrapper.cpp 4KB
hl_types.h 3KB
Makefile 6KB
hl_sha256wrapper.h 4KB
hl_md5wrapper.cpp 4KB
.hashlibpp.h.swp 12KB
hl_md5.cpp 13KB
hl_wrapperfactory.h 3KB
hl_md5.h 7KB
hl_sha256.h 6KB
hl_sha1.h 7KB
hl_hashwrapper.h 9KB
hl_sha384wrapper.cpp 4KB
hl_sha256.cpp 14KB
hl_sha256wrapper.cpp 4KB
hl_sha2mac.h 8KB
hl_wrapperfactory.cpp 3KB
.svn
prop-base
text-base
hl_sha1wrapper.cpp.svn-base 4KB
hl_sha2ext.cpp.svn-base 17KB
hashlibpp.h.svn-base 2KB
hl_exception.h.svn-base 3KB
hl_sha384wrapper.h.svn-base 4KB
hl_md5.cpp.svn-base 13KB
hl_sha512wrapper.cpp.svn-base 4KB
hl_sha256.h.svn-base 6KB
hl_wrapperfactory.cpp.svn-base 3KB
hl_sha256.cpp.svn-base 14KB
hl_types.h.svn-base 3KB
hl_md5.h.svn-base 7KB
hl_md5wrapper.h.svn-base 4KB
hl_sha384wrapper.cpp.svn-base 4KB
hl_sha2ext.h.svn-base 8KB
hl_sha1.h.svn-base 7KB
hl_sha1wrapper.h.svn-base 4KB
hl_sha2mac.h.svn-base 8KB
hl_md5wrapper.cpp.svn-base 4KB
hl_hashwrapper.h.svn-base 9KB
hl_sha1.cpp.svn-base 11KB
hl_wrapperfactory.h.svn-base 3KB
hl_sha512wrapper.h.svn-base 4KB
hl_sha256wrapper.h.svn-base 4KB
hl_sha256wrapper.cpp.svn-base 4KB
Makefile.svn-base 6KB
props
tmp
prop-base
text-base
props
entries 4KB
all-wcprops 3KB
hl_sha1wrapper.h 4KB
hl_md5wrapper.h 4KB
hl_sha1wrapper.cpp 4KB
hl_sha2ext.cpp 17KB
hl_sha1.cpp 11KB
hl_sha2ext.h 8KB
hl_exception.h 3KB
hl_sha384wrapper.h 4KB
hl_sha512wrapper.h 4KB
hashlibpp.h 2KB
.svn
prop-base
text-base
props
tmp
prop-base
text-base
props
entries 268B
all-wcprops 80B
共 91 条
- 1
资源评论
新华
- 粉丝: 8477
- 资源: 609
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功