alanonymous has asked for the wisdom of the Perl Monks concerning the following question:
This *should* break the string into couplets, then for each couplet, turn it into the hex value of it's string hex self, then convert that hex value into ASCII with chr. It doesn't seem to work though :/my @ar = $t1 =~ /(..)/g; $foo->delete("1.0","end"); foreach (@ar) { $foo->insert("1.0",chr(pack("H*",$_))); }
I'm still having trouble taking the hex string and finding the ascii character for it. Just testing:$txt3->delete("1.0","end"); my $hexor = unpack('h*',pack('h*',$t1) ^ pack('h*',$t2)); $txt3->insert("1.0",$hexor);
***********************************************************my $hhh = unpack('h*',pack('h*',"20") ^ pack('h*',"61")); #xor ' ' and + 'a' should result in 'A' print unpack('h*',$hhh);
Thank you everyone for the help! And Marshall, I think you helped me last time I had a random question too!sub parse () { my $t1 = $txt1->Contents(); my $t2 = $txt2->Contents(); chomp($t1); chomp($t2); $txt3->delete("1.0","end"); my $hexor = unpack('h*',pack('h*',$t1) ^ pack('h*',$t2)); $txt3->insert("1.0",$hexor); my @ar = $hexor =~ /(..)/g; $txt33->delete("1.0","end"); foreach (@ar) { if (chr(hex($_)) =~ /[a-zA-Z]/) { $txt33->insert("end",chr(hex($_))); } else { $txt33->insert("end","~"); } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hex String XOR
by moritz (Cardinal) on Mar 12, 2012 at 09:02 UTC | |
by ikegami (Patriarch) on Mar 12, 2012 at 18:45 UTC | |
|
Re: Hex String XOR
by Marshall (Canon) on Mar 12, 2012 at 08:48 UTC | |
|
Re: Hex String XOR
by Not_a_Number (Prior) on Mar 12, 2012 at 09:05 UTC | |
by Marshall (Canon) on Mar 12, 2012 at 09:21 UTC | |
|
Re: Hex String XOR
by rovf (Priest) on Mar 12, 2012 at 09:25 UTC | |
by moritz (Cardinal) on Mar 12, 2012 at 09:52 UTC | |
by tobyink (Canon) on Mar 12, 2012 at 11:30 UTC | |
by flexvault (Monsignor) on Mar 12, 2012 at 18:48 UTC | |
by tobyink (Canon) on Mar 13, 2012 at 01:19 UTC | |
by ikegami (Patriarch) on Mar 12, 2012 at 18:48 UTC | |
|
Re: Hex String XOR
by Marshall (Canon) on Mar 12, 2012 at 10:39 UTC | |
by JavaFan (Canon) on Mar 12, 2012 at 11:16 UTC | |
by Marshall (Canon) on Mar 12, 2012 at 12:31 UTC | |
by Anonymous Monk on Jun 23, 2015 at 13:08 UTC |