Re: Tools for checking randomness
From: Anon E. Maus (anaon_at_maus.duh)
Date: 08/04/03
- Next message: Tom St Denis: "Re: Release 1.3 of my AES implementation"
- Previous message: Bryan Olson: "Re: Magic Flight: latest version of a public-key algorithm using max-plus algebra"
- In reply to: Eris Pluvia: "Tools for checking randomness"
- Next in thread: LVB: "Re: Tools for checking randomness"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Mon, 04 Aug 2003 11:49:47 GMT
"Eris Pluvia" <eris_pluviaNOSPAM@yahoo.es> wrote in message
news:bgl9eo$pqe0r$1@ID-158102.news.uni-berlin.de...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> That is. I'm looking for programs or libraries to check the output of a
> PRNG.
>
> I also thanks any other advise on this topic. For example if I may program
> some simple test that could reveal biasing or other unwanted features.
>
> TIA
>
> - --
> Eris Pluvia
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.1 (GNU/Linux)
>
> iD8DBQE/LikRJGhdcRi+KGwRArirAJ9eNP3fEAXoZnxO8kRloq4yg+I+ggCeN/Qi
> Haou090+kysDNPq4FtyAaLQ=
> =Eh/l
> -----END PGP SIGNATURE-----
Here's a quickie for you - enjoy. In VC6.0, shouldn't be hard to port
anywhere you want.
Histogram.h
#if
!defined(AFX_HISTOGRAM_H__1A45D961_7DDB_4E7D_9EC3_0D22D8AC9656__INCLUDED_)
#define AFX_HISTOGRAM_H__1A45D961_7DDB_4E7D_9EC3_0D22D8AC9656__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "resource.h"
#endif //
!defined(AFX_HISTOGRAM_H__1A45D961_7DDB_4E7D_9EC3_0D22D8AC9656__INCLUDED_)
Resource.h
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by HistoGram.rc
//
#define IDS_HELLO 1
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
// HistoGram.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "HistoGram.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
////////////////////////////////////////////////////////////////////////////
/
// The one and only application object
CWinApp theApp;
using namespace std;
extern LPCTSTR GetErrorMnemonic(int nCode);
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
return nRetCode;
}
DWORD rgdwCount[256];
int i, x;
BYTE buf[1024];
for(i = 0; i < 256; i++)
rgdwCount[i] = 0;
CFile cf;
if(!*argv[1])
return -1;
cf.Open(argv[1], CFile::modeRead);
if(cf.m_hFile == (UINT) CFile::hFileNull)
{
printf("Fatal Error: (%s) could not open %s\n",
GetErrorMnemonic(GetLastError()), cf.GetFileName());
return GetLastError();
}
printf("Reading %s", cf.GetFileName());
BYTE c;
for(;;)
{
try
{
x = cf.Read(buf, 1024);
}
catch(CFileException *e)
{
printf("Fatal Error: (%s) could not read %s\n",
GetErrorMnemonic(e->m_lOsError), cf.GetFileName());
return e->m_lOsError;
}
catch(...)
{
cf.Close();
cout << "Error reading file!" << endl << endl;
}
for(i = 0; i < x; i++)
{
c = buf[i];
++rgdwCount[c];
}
if(x < 1024)
break;
cout << ".";
}
cf.Close();
cout << endl << endl;
for(i = 0; i < 256; i++)
printf("%03d %c\t%d\n", i, isprint(i)? i : '.', rgdwCount[i]);
return nRetCode;
}
- Next message: Tom St Denis: "Re: Release 1.3 of my AES implementation"
- Previous message: Bryan Olson: "Re: Magic Flight: latest version of a public-key algorithm using max-plus algebra"
- In reply to: Eris Pluvia: "Tools for checking randomness"
- Next in thread: LVB: "Re: Tools for checking randomness"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|