A small meditation on a current project.
You have an sql db and are going to dynamically generate a record-input screen with Perl script. First temptation is do something like this (pseudo-code):
and then the reverse when the form is submitted. BUT, I've now given away the actual column names of my table - one small piece of real info for hackers to exploit.$sql = "show columns from my_table"; execute while (there are $field_names) { print "<input type='text' name='".$field_name."'>" }
I could, instead, have a hash of "public" names:
But now I have this intermediate association table to maintain. Sooooo, I thought a nifty alternative would be a home-made field name encoder/decoder:$public_names{$field_1} = "foo"; $public_names{$field_2} = "bar"; foreach $key (keys %public_names) { print "<input type='text' name='".$public_names{$key}."'>" }
with a corresponding decode sub for the returning values in the submitted form. No association tables to maintain - and my field name info is secure.$sql = "show columns from my_table"; execute while (there are $field_names) { $public_name = &encode($field_name); print "<input type='text' name='".$public_name."'>" } sub encode() { $scrambled =~ tr/[a-z]/[w,t,5,s,c,....,7,a]/; return $scrambled; }
Wadda y'all think?
|
|---|