Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Simple perl encoder

by BrowserUk (Pope)
on Sep 28, 2011 at 00:25 UTC ( #928207=note: print w/ replies, xml ) Need Help??


in reply to Simple perl encoder

A few years ago I saw a code that converted everything to 1s and 0s and it was easy to encode and decode from that but I can't find it.

Bit-wise not (~) applied to a string does exactly that very efficiently:

$s = 'The quick brown fox jumps over the lazy dog';; print unpack 'C*', $s;; 84 104 101 32 113 117 105 99 107 32 98 114 111 119 110 32 102 111 120 +32 106 117 109 112 115 32 111 118 101 114 32 116 104 101 32 108 97 12 +2 121 32 100 111 103 $t = ~$s;; print unpack 'C*', $t;; 171 151 154 223 142 138 150 156 148 223 157 141 144 136 145 223 153 14 +4 135 223 149 138 146 143 140 223 144 137 154 141 223 139 151 154 223 + 147 158 133 134 223 155 144 152 $u = ~$t;; print unpack 'C*', $u;; 84 104 101 32 113 117 105 99 107 32 98 114 111 119 110 32 102 111 120 +32 106 117 109 112 115 32 111 118 101 114 32 116 104 101 32 108 97 12 +2 121 32 100 111 103 print $u;; The quick brown fox jumps over the lazy dog

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re: Simple perl encoder
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://928207]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2014-09-02 21:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (29 votes), past polls