Skip to content

A lightweight Qt C++ library providing some of the cryptographic hash algorithms not supported by QCryptographicHash

License

Notifications You must be signed in to change notification settings

rikyoz/QtCryptoHash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QtCryptoHash Build Status

QtCryptoHash is a Qt C++ library providing a way to calculate some of the cryptographic hashes not supported by the QCryptographicHash class from the Qt library.

Features

  • Supports Tiger-192, RipeMD-160 and Whirlpool algorithms
  • Simple interface, identical to the QCryptographicHash class, but renamed QCryptoHash
  • Works with Qt 5.x
  • Supports MSVC, MinGW, GCC and Clang

Basic Usage

String Hash Calculation

#include "qcryptohash.hpp"
...
QByteArray stringHash = QCryptoHash::hash( "abc", QCryptoHash::TIGER );
qInfo() << stringHash.toHex(); //f258c1e88414ab2a527ab541ffc5b8bf935f7b951c132951

File Hash Calculation

#include "qcryptohash.hpp"
...
QFile file( filename );
if ( file.open( QFile::ReadOnly ) ) {
	QCryptoHash ripemdHash( QCryptoHash::RMD160 );
	while( !file.atEnd() ){
		ripemdHash.addData( file.read( 8192 ) );
	}
	QByteArray fileHash = ripemdHash.result();	
	qInfo() << fileHash.toHex(); //RipeMD hash of 'filename' file content
}

For a complete description of the QCryptoHash API, see the relative wiki.

Dependencies

QtCryptoHash needs only QtCore library to be linked to the program.

Building

A complete guide to build this library is available here.

License (GPL v2)

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.