Hide a string while saving it to file
I have a string (ascii). I would like to apply a rule on it before saving it to a file -> coding ... And apply the same rule to get the original string while reading from the file -> decoding ... Any Idea ? Thanks, José. DISCLAIMER "This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer". Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent.
Re: Hide a string while saving it to file
Nyimi Jose wrote: > I have a string (ascii). > I would like to apply a rule on it before saving it to a file -> coding > ... And apply the same rule to get the original string while reading from > the file -> decoding ... > > Any Idea ? there are ency/decy modules in CPAN that you should check out. for a brain-dead appoach try: #!/usr/bin/perl -w use strict; my $i = "abcd"; my $j = mess_it($i); print "$j\n"; print fix_it($j),"\n"; sub fix_it{ my $s = shift; $s =~ s#(.)#chr(ord($1)/2)#ge; return $s; } sub mess_it{ my $s = shift; $s =~ s/(.)/chr(ord($1)*2)/ge; return $s; } __END__ anyone who knows a little Perl can easily figure out a way to decode the mess-ed string. it's not secure at all. but if you just want to prevent users from looking at your data, that might help. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Hide a string while saving it to file
On Thu, Sep 26, 2002 at 04:07:20PM +0200, NYIMI Jose (BMB) wrote: > I have a string (ascii). > I would like to apply a rule on it before saving it to a file -> coding > ... And apply the same rule to get the original string while reading from > the file -> decoding ... > > Any Idea ? I don't understand, where is your problem? Are you asking for help on opening a file and writing to it? Are you asking for help on how to encode and decode a string? Are you asking for help on opening a file and reading from it? All of the above? What have you tried? What learning material do you have? See learn.perl.org for references on good learning material. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Hide a string while saving it to file
> -Original Message- > From: david [mailto:[EMAIL PROTECTED]] > Sent: Thursday, September 26, 2002 8:41 PM > To: [EMAIL PROTECTED] > Subject: Re: Hide a string while saving it to file > > > Nyimi Jose wrote: > > > I have a string (ascii). > > I would like to apply a rule on it before saving it to a file -> > > coding ... And apply the same rule to get the original string while > > reading from the file -> decoding ... > > > > Any Idea ? > > there are ency/decy modules in CPAN that you should check out. for a > brain-dead appoach try: > > #!/usr/bin/perl -w > use strict; > > my $i = "abcd"; > > my $j = mess_it($i); > print "$j\n"; > print fix_it($j),"\n"; > > sub fix_it{ > my $s = shift; > $s =~ s#(.)#chr(ord($1)/2)#ge; > return $s; > } > > sub mess_it{ > my $s = shift; > $s =~ s/(.)/chr(ord($1)*2)/ge; > return $s; > } > > __END__ > > anyone who knows a little Perl can easily figure out a way to > decode the > mess-ed string. it's not secure at all. but if you just want > to prevent > users from looking at your data, that might help. That's ok for what I want. Thanks a lot ... José. DISCLAIMER "This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer". Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Hide a string while saving it to file
> -Original Message- > From: david [mailto:[EMAIL PROTECTED]] > Sent: Thursday, September 26, 2002 8:41 PM > To: [EMAIL PROTECTED] > Subject: Re: Hide a string while saving it to file > > > Nyimi Jose wrote: > > > I have a string (ascii). > > I would like to apply a rule on it before saving it to a file -> > > coding ... And apply the same rule to get the original string while > > reading from the file -> decoding ... > > > > Any Idea ? > > there are ency/decy modules in CPAN that you should check out. for a > brain-dead appoach try: > > #!/usr/bin/perl -w > use strict; > > my $i = "abcd"; > > my $j = mess_it($i); > print "$j\n"; > print fix_it($j),"\n"; > > sub fix_it{ > my $s = shift; > $s =~ s#(.)#chr(ord($1)/2)#ge; I did know that it was possible to use # character instead of the / one, while substution. I understand why you use it :-) (because of division operator). So my question is : Are there others characters that I can use in substitution statement instead of the "normal" / char ? DISCLAIMER "This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer". Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Hide a string while saving it to file
Nyimi Jose wrote: > > > From: david [mailto:[EMAIL PROTECTED]] > > > > sub fix_it{ > > my $s = shift; > > $s =~ s#(.)#chr(ord($1)/2)#ge; > > I did know that it was possible to use # character instead of the / one, > while substution. I understand why you use it :-) (because of division > operator). So my question is : > Are there others characters that I can use in substitution statement > instead of the "normal" / char ? Yes. perldoc perlop [snip] If "/" is the delimiter then the initial `m' is optional. With the `m' you can use any pair of non-alphanumeric, non-whitespace characters as delimiters. This is particularly useful for matching path names that contain "/", to avoid LTS (leaning toothpick syndrome). If "?" is the delimiter, then the match-only-once rule of `?PAT TERN?' applies. If "'" is the delimiter, no interpolation is performed on the PATTERN. [snip] Any non-alphanumeric, non-whitespace delimiter may replace the slashes. If single quotes are used, no interpretation is done on the replacement string (the `/e' modifier overrides this, how ever). Unlike Perl 4, Perl 5 treats backticks as normal delimiters; the replacement text is not evaluated as a command. If the PATTERN is delim ited by bracketing quotes, the REPLACEMENT has its own pair of quotes, which may or may not be brack eting quotes, e.g., `s(foo)(bar)' or `s/bar/'. This applies to all the quote and quote-like operators (m//, s///, q//, qq//, qw//, qr//, and qx//) and the transliteration operators (tr/// and y///.) John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Hide a string while saving it to file
Try this to encode your file. Decoding I beleive you can do. open (FILE, "C:\\perl\\original\.txt" ) or die ; open (FILE1,">C:\\perl\\converted\.txt") or die ; while () { @ascii = unpack("C*", $_); foreach $val (@ascii) { $val++; } $_ = pack("C*", @ascii); print FILE1; } close(FILE); close(FILE1); regards Rajendran Burlingame,CA - Original Message - From: "NYIMI Jose (BMB)" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, September 26, 2002 7:07 AM Subject: Hide a string while saving it to file I have a string (ascii). I would like to apply a rule on it before saving it to a file -> coding ... And apply the same rule to get the original string while reading from the file -> decoding ... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]