Anton Ganeshalingam wrote:
Let's say my data is the following phrase 'Hello World'. This phrase is
represented in machine language in bits (assuming I'm right). So this was
the reason I thought I could insert the data into MS db after shifting a
bit.


Well, you'd have to left shift - and then right shift by the same amount to retrieve the original data. (If you right shift first you'll lose information.) So you'll probably be printing wide characters to the database. Is that going to pose a problem ? (I don't know the answer to that question.)


If you're trying to hide the data then there's probably a better solution - eg use one of the encryption modules.

But here's one answer to (what I think is) your question. You just replace 'H' with
chr(ord('H') << $shift), and do likewise for each of the other characters in the string.


my $c = 'Hello World';
my $len = length($c);
my $shift = 3;

for(my $i = 0; $i < $len; $i++) {
   substr($c, $i, 1, chr(ord(substr($c, $i, 1)) << $shift));
   }

print $c, "\n";

# To recover the info:
for(my $i = 0; $i < $len; $i++) {
   substr($c, $i, 1, chr(ord(substr($c, $i, 1)) >> $shift));
   }

print $c, "\n";

__END__

Cheers,
Rob


_______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to