Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Random String Detection

Tags:

java

algorithm

I need to check if a string is fairly random without performing frequency analysis because it will be too time consuming. Is there such algorithm already out there? I am building this with java but a generic description of an algorithm will be also very useful.

Clarification: To the human eye, the following text is somehow random.... dsfsddsfdsfsddsfs .... or even po340-3gk30g3gkf;glkp.

I don't want to know for sure how random it is. I just want to detect, pretty much the way a human being will, if a string is random looking without measuring it's actual randomness.

like image 802
Pass Avatar asked Oct 21 '25 15:10

Pass


1 Answers

I need to check if a string is fairly random without performing frequency analysis because it will be too time consuming.

A simple frequence analysis is basically the fastest thing I can imagine. You just traverse the characters in the string (once) and keep track of the counts.

I can't imagine you can find any "randomness-test" that is faster than this.

Besides, I can't really say that your question is clear. Technically any string is as random as any other. If you're after what "looks" random, I suppose you need to look for all kinds of patterns, and this will for sure be too time-consuming for you.

Is this random in your opinion:

String str = "                      o         _        _            _        "
           + "           _o        /\_      _ \\o     (_)\__/o     (_)       "
           + "         _< \_      _>(_)    (_)/<_       \_| \      _|/' \/   "
           + "        (_)>(_)    (_)           (_)      (_)       (_)'  _\o_ ";

It doesn't look very random to me, but I'd have a hard time to define what looks random.

like image 116
aioobe Avatar answered Oct 23 '25 03:10

aioobe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!