Click here to Skip to main content
Full site     10M members (35.3K online)    

BlakeSharp - A C# Implementation of the BLAKE Hash Algorithm

Contents

BLAKE and BlakeSharp

BlakeSharp is my implementation of the BLAKE algorithm written in C#. It is public domain, i.e., you may freely include/use it in your projects (also commercial ones). If you're using it, it would be nice if you'd mention me somewhere in the documentation of your program, but it's not required.

BLAKE is a cryptographically secure one-way hash function. It was designed by Jean-Philippe Aumasson, Luca Henzen, Willi Meier, and Raphael C.-W. Phan. BLAKE is one of the five finalists in NIST's SHA-3 competition. For more information on BLAKE, see the official BLAKE website.

BlakeSharp was derived from the reference C implementation of BLAKE. All code was rewritten in C#, i.e., only managed code is used now, no native or unsafe code. Thus it's portable and runs fine under both .NET (Windows) and Mono (Linux / Mac OS X / ...).

Including BlakeSharp in Your Project

BlakeSharp consists of two classes that implement the two main instances of BLAKE: the Blake256 class implements the 256-bit version of BLAKE (BLAKE-256, producing a 256-bit = 32 bytes long hash), and the Blake512 class implements the 512-bit version of BLAKE (BLAKE-512, producing a 512-bit = 64 bytes long hash). The two classes are independent of each other (i.e., when you only need the 256-bit version, you don't need to include the 512-bit code, and vice versa).

There are two different ways you can include BlakeSharp:

Blake256.cs and Blake512.cs can be found in the BlakeSharp folder in the downloadable package. A compiled BlakeSharp.dll is in Build/BlakeSharp/Release.

Using BlakeSharp

The two classes (Blake256 and Blake512) are derived from the HashAlgorithm .NET base class. Consequently the classes are being used the very same as other hash algorithm classes of the .NET framework, like e.g., SHA1Managed or SHA256Managed.

Some usage examples:

The Demo Application

The downloadable package contains a demo application called BlakeSharpDemo, which can hash strings and files. A compiled executable BlakeSharpDemo.exe can be found in Build/BlakeSharpDemo/Release.

BlakeSharpDemo.exe can be invoked with the following command line parameters:

Examples:

In order to run BlakeSharpDemo under Mono (Linux / Mac OS X / ...), prepend "mono" to the command lines above.

That's it! Happy hashing!

Version History

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search 
Per page   
GeneralMy vote of 5
Prasad Khandekar
18 Mar '13 - 22:05 
QuestionHosted from within XCrypt
Vasudevan Deepak Kumar
24 Oct '12 - 10:20 
GeneralMy vote of 5
Abinash Bishoyi
24 Sep '12 - 6:27 
GeneralMy vote of 5
hsback
9 Apr '12 - 5:49 
GeneralMy vote of 5
Member 4320844
6 Jan '12 - 7:38 
Questionmy alternative project with all sha3 candidates
tomanu
28 Nov '11 - 1:59 
Generaleven on silverlight.. thanks.
Leonardo Paneque
23 Nov '11 - 9:05 
QuestionCan i Use this in commercial application
albert arul prakash
21 Nov '11 - 0:08 
AnswerRe: Can i Use this in commercial application
Dominik Reichl
21 Nov '11 - 8:18 
GeneralMy vote of 5
pooya_p
20 Nov '11 - 22:25 
GeneralMy vote of 5
HaBiX
20 Nov '11 - 21:43 
GeneralMy vote of 5
Kanasz Robert
20 Nov '11 - 10:40 
GeneralMy vote of 5
Filip D'haene
20 Nov '11 - 8:43 

Last Updated 20 Nov 2011 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2013