[AccessD] Announcing (Proposing) the First Annual DBA AccessObfuscation Contest

Jim Lawrence (AccessD) accessd at shaw.ca
Sat Aug 14 02:07:14 CDT 2004


Here is a modest contribution, of a function, from some old code (Goes back
fifteen years and I still support this site.)

A few hints as to how the language works:

1. All variable must be declared, are case sensitive, prefixed with a '$'
sign, but the built in functions are not case sensitive.
2. The '\' symbol is used as a wrap line like VBA's '& _'.
3. It uses the 'Return' statement instead of VBA's weird 'check_date =
$error' coding structure.
4. All functions calls must be prefixed with a '_'.
5. True = 1 and False = 0
6. 'Match''s matches are case sensitive and is similar to a variation of the
'Instr' function.
7. A phrase like (a = b) will produce either a 1 or a 0. (True or False)
8. Variables a not pre-typed but once initialized with a numeric or string
will then behave as if they were typed.

FUNCTION _check_date($temp)

 LOCAL $month, $day, $year, $back1, $back2, $deliminator

 $error    = 1

 if val(right($temp,4)) > 1900
  $year = val(right($temp,4))
  if len(trim($temp)) = 11
   $month = proper(mid($temp,4,3))
   $month = (match("JanFebMarAprMayJunJulAugSepOctNovDec",$month)+2)/3
   $day = val(left($temp,2))
  else
   $month = val(left($temp,2))
   $day = val(mid($temp,4,2))
  end if

  $deliminator = mid($temp,3,1)
  $back1 = $deliminator
  $back2 = $deliminator
 else
  $temp  = LEFT($temp,8)

  $month =  VAL ( LEFT ( $temp,2 ) )
  $day   =  VAL ( MID ( $temp,4,2 ) )
  IF LEN($temp) = 10
   $year =  VAL ( RIGHT ( $temp,4 ))
  ELSE
   $year =  VAL ( RIGHT ( $temp,2 ))
  END IF
  $deliminator = mid($temp,3,1)
  $back1 =  MID ( $temp,3,1 )
  $back2 =  MID ( $temp,6,1 )
 end if

 IF ($year * ( $back1 = $deliminator ) * $month * ( $back2 = $deliminator )
* ( $day )) > 0
  IF ($month <= 12 AND $day <= 31)
   IF (( MATCH ( "469",STR($month)) OR $month = 11 ) AND $day < 31 )\
      OR (( $month = 2 AND MOD( $year,4 ) AND $day < 29 )\
      OR ( $month = 2 AND NOT ( MOD ( $year,4 )) AND $day < 30 ))\
      OR ( MATCH ( "1357810",STR($month)) OR $month = 12 )
      $error = 0
   END IF
  END IF
 END IF
 RETURN($error)
END FUNCTION

It is not actually Access, as if you haven't guessed but if anyone had the
mind they could convert it.... It is not fair to use Access's extensive
function library to resolve the previous function just keep it simple and
similar. Now what does the previous function do?

Previously, two other programmers have attempted to manage the fifty plus
code blocks, at an estimated 8.5 thousand lines of code, and quit, shortly
after starting. Above is just a small snippet from one functions from one of
the libaries. So if anyone feels in a masochistic mood or feels particularly
brave, try and convert it to VBA.

Jim Lawrence

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Arthur Fuller
Sent: Thursday, August 12, 2004 10:14 AM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] Announcing (Proposing) the First Annual DBA
AccessObfuscation Contest


The Naming Conventions thread has been most interesting and has prompted
me to suggest an annual contest a la the classic DDJ C-Obfuscation
contest. The point is to write a geruinely incomprehensible routine that
does something useful. It would only make sense if we confined ourselves
to say 5 candidate routines, Access-specific of course. Contributors
could then submit a "solution" to any of the 5 problems. (A double-prize
might be considered for code that does not even make it apparent which
problem it is solving!)

Step 1 is to gather the list of problems. I venture the following merely
as a starting point. I haven't given any of them a lot of consideration,
they are nothing more than something to shoot at, if you will. Somehow
let's settle on 5 problems worth obfuscating. After that, obfuscation
will be, heh heh, obvious.

Herewith, 5 problems. Please feel free to shoot them down as
insignificant or not worth writing etc. I would love to have the list
come up with 5 genuinely interesting problems, on which to base the
obfuscated solutions. None of them would be immediately useful in
anyone's current project, but I think it would be fun to see the
variants that contestants come up with.

Five initial examples. Fire at will. Please come up with more
interesting problems!

1. For every open form
	for every textbox
		make it read-only
		change the colours

2. Given tables Parent and Child, delete every third Parent record and
all her children in the Child table.

3. Manufacture some test data in 4 tables: parent, child1, child2, and
child2's child. The routine accepts the number of parents to create and
the maximum number of child rows to create. Then it randomly adds kids
(and grandkids) to tables 2, 3 and 4 for each parent, using the
specified maximum.

4. Delete every file from every directory to which the user has access,
while presenting warm and fuzzy messages. (Don't really delete them,
just print a message suggesting that could have. Option: Tell them you
HAVE deleted them, and offer recovery for $.05 a file. Bring up PayPal
to complete the transaction.

5. Create an email to every person in your Outlook Contacts folder,
announcing that your surgery was unsuccessful and you are now a
refridgerator salesperson in Resolute Bay.

Five stupid problems, I admit. Let's come up with five smart problems
and then obfuscate their solutions! (At the least, each problem could
become an issue of our newsletter, including the various solutions sent
in by listers.)

One obvious obfuscation technique is purposeful misuse of Hungarian.

Dim strValue as Long     ' the number of striations per meter of a given
cave wall.
Dim datLast as Currency  ' how much you paid the hooker for your last
"date".
Dim booLevel as Byte     ' scare factor in a horror movie focus group.
Dim booLevel as Long     ' WWE measurement as reported by microphones.
Dim cboAvail as Boolean  ' is this jazz musician available for work in a
combo?

But there are many more. Table names offer abundant opportunities to
play.

You get the idea, I hope....
Arthur

--
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list