Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quick and practical test to see if a string is random

Tags:

c#

random

I need to understand if a string is sufficiently random or not. Can anyone point me in the right direction?

Background

I need to emulate a process behaviour, where a process copies itself to a temp location, renames itself to a random name, and executes itself. My ultimate goal is to detect such activity. As part of this work I need to test a process name, which is a string, for randomness. I understand that Kolmogorov complexity deals with this, but it is incomputable. What would be quick alternatives: variety of entropies, Lempel-Ziv compression level?

What I look for

string s1 = "test process name"
string s2 = "hgoi4dFh3e905jv"

double sensitivity = 0.5; // user-defined variable, a subjective threshold of randomness
bool b1 = SeemsRandom(s1, sensitivity);  // false
bool b2 = SeemsRandom(s2, sensitivity);  // true

bool SeemsRandom(string input, double sensitivity)
{
    ...
}
like image 793
oleksii Avatar asked Mar 25 '14 13:03

oleksii


1 Answers

You may want to try converting the string to a binary sequence and try using the Wald-Wolfowitz runs test which should be less complicated than Kolmogorov–Smirnov test

http://en.wikipedia.org/wiki/Wald%E2%80%93Wolfowitz_runs_test

like image 163
ommehta Avatar answered Sep 28 '22 09:09

ommehta