Giter Site home page Giter Site logo

cubehash.cs's Introduction

CubeHash.cs source code package - C# implementation

2016-08-19
Uli Riehm <[email protected]>
Public Domain

based on supercop-20141124/crypto_hash/cubehash512/unrolled2

20100726
D. J. Bernstein
Public domain.

Ask questions on stackoverflow using tags C#``CubeHash !

Usage 1

Have "one" CubeHash value.

using Crypto;
using System;
using System.Text;


	string text = "HHHHAAAALLLLOOOOWWWWEEEELLLLTTTT";
	byte[] bytes = Encoding.UTF8.GetBytes(text);
	byte[] value;

	using (var hash = new CubeHash512()) value = hash.ComputeHash(bytes);

	foreach (byte v in value) Console.Write("{0:x2}", v);
	Console.WriteLine();

Usage 2

Have "many" CubeHash values.

using Crypto;
using System;
using System.Text;


	byte[] textBytes = Encoding.UTF8.GetBytes("HHHHAAAALLLLOOOOWWWWEEEELLLLTTTT");

	byte[] hashSource = new byte[sizeof(UInt32) + textBytes.Length];
	Buffer.BlockCopy(textBytes, 0, hashSource, sizeof(UInt32), textBytes.Length);

	var hashValue = new byte[64];

	UInt32 i = 0; // threadI;

	using (var hash = new CubeHash512())
	{
		do
		{
			CubeHash.UInt32ToBytes(i, hashSource, 0);

			hash.Compute(hashValue, hashSource);

			// if (Quersumme(i + 1) == 1) Console.WriteLine ...

		} while (0 < ++i);

		/* Beware. Your program will run FOR HOURS !

		   2016-08-21 13.46.00
		   Intel Pentium Dual CPU E2160 @ 1.80GHz x2

		     100.000.000 CubeHash512 in 14min 08sec
		   ==  100000000 ÷ (14×60 + 08)
		   :=    117.925 CubeHash512/s

		1. Run this using a pipe, on GNU/Linux and on Windows

		   $ mono ./YourProgram.exe > './YourPrograms output.txt'

		2. Use `emacs` as your editor.

		   Press `M-x auto-revert-mode`
		   or use file `~/.emacs.d/init.el` with `(global-auto-revert-mode 1)`,

		   to have a real-time view of your program.

		3. Also try this using new System.Threading.Thread's:

		} while (threadI < (i += threadC)); /**/
	}

	foreach (byte v in hashValue) Console.Write("{0:x2}", v);
	Console.WriteLine();

Example 1

~/CubeHash.cs/bin/Debug $ echo -n HHHHAAAALLLLOOOOWWWWEEEELLLLTTTT > ./Hallo.txt

~/CubeHash.cs/bin/Debug $ hexdump ./Hallo.txt 
0000000 4848 4848 4141 4141 4c4c 4c4c 4f4f 4f4f
0000010 5757 5757 4545 4545 4c4c 4c4c 5454 5454
0000020

~/CubeHash.cs/bin/Debug $ mono ./CubeHash.exe --in=./Hallo.txt
8e335ae82903d3d6557d60e6a7f231e54443f2ad2226e5c1f2db8f8d0112ada28637d9be275171a47e80b22f8aea716e97850083a9d27f361026501f2251e05b

~/CubeHash.cs/bin/Debug $ mono ./CubeHash.exe --in=./Hallo.txt CubeHash256
c1f8e0e6a7f49697c16d86894e06c0d9f286532ec0e64de2277a0a14ca167e01

cubehash.cs's People

Contributors

metadings avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

tmlawless

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.