Obfuscation challenge
Posted: Fri Nov 02, 2007 12:33 am
I've given a quick attempt:
So the source is incomplete...but it demonstrates the idea...
Basically the idea is to generate a unique variable but instead of generating lengthly ID's such as 7EH3DHBFYRF7RBFVGHY I want to generate names in the following pattern:
a
b
c
d
e
..
_
Then...
aa
ab
ac
ad
ae
af
ag
ah
ai
Then...
ba
bb
bc
bd
be
bf
bg
...
Then...
ca
cb
cc
cd
ce
...
You get the idea.
I'm curious to see what others might come up with...
p.s-I use statics because the unique ID is generated on each call to the function.
Anybody?
Code: Select all
function generateUniqueId()
{
static $entry = 0;
static $index = 0;
$valid = array('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789');
if($entry == 0){
$value = $valid{0}; // First time funciton is called make sure we use lower case 'a' as the first character
$entry = 1;
$index = 1; // Use next character in array next call
}
else{
// NOTE: I'm starting to become discombobulated - so I'll leave it here
if($index < strlen($valid) && $depth){
$value = $valid{$index};
}
$index++;
}
return $value;
}Basically the idea is to generate a unique variable but instead of generating lengthly ID's such as 7EH3DHBFYRF7RBFVGHY I want to generate names in the following pattern:
a
b
c
d
e
..
_
Then...
aa
ab
ac
ad
ae
af
ag
ah
ai
Then...
ba
bb
bc
bd
be
bf
bg
...
Then...
ca
cb
cc
cd
ce
...
You get the idea.
I'm curious to see what others might come up with...
p.s-I use statics because the unique ID is generated on each call to the function.
Anybody?