Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Perl Question

Perl Question
Thread Tools
nonhuman
Posting Junkie
Join Date: Jun 2001
Location: Baltimore, MD
Status: Offline
Reply With Quote
Dec 23, 2001, 10:37 AM
 
Okay, being on break as I am, I'm generally pretty bored. I just reread Cryptonimicon and for the hell of it decided to try out "Solitaire" or "Pontifex" crypto system that's described in the book. The following is provided in the book as the perl version of the encryption algorith:

<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>#!/usr/bin/perl -s
$f=$d?<font color = blue>-1</font>:<font color = blue>1</font>;$D=pack('C*',<font color = blue>33.</font>.<font color = blue>86</font>)$p=shift;
$p=~y/a-z/A-Z/;$U='$D=~s/(.*)U$/U$<font color = blue>1</font>/;
$D=~s/U(.)/$1U/;';($V=$U)=~s/U/V/g;
$p=~s/[A-Z]/$k=ord($&)<font color = blue>-64</font>,$e/eg;$k=<font color = blue>0</font>;
while(&lt;&gt; ){y/a-z/A-Z/;y/A-Z<font color = brown>//dc;$o.=$_}$o.='X'</font>
while length ($o)%<font color = blue>5</font>&&!$d;
$o=~s/./chr(($f*&e+ord($&)<font color = blue>-13</font>)%<font color = blue>26</font>+<font color = blue>65</font>)/eg;
$o=~s/X*$<font color = brown>// if $d;$o=~s/.{<font color = blue>5</font>}/$& /g;</font>
print<font color = red>"$o/n"</font>;sub v{$v=ord(substr($D,$_[<font color = blue>0</font>]))<font color = blue>-32</font>;
$v&gt;<font color = blue>53</font>?<font color = blue>53</font>:$v}
sub w{$D=~s/(.{$_[<font color = blue>0</font>]})(.*)(.)/$<font color = blue>2</font>$<font color = blue>1</font>$<font color = blue>3</font>/}
sub e{eval<font color = red>"$U$V$V"</font>;$D=~s/(.*)([UV].*[UV])(.*)/$#$@$!/;
&w(&v(<font color = blue>53</font>));$k?(&w(&k)) $c=&v(&v(<font color = blue>0</font>)),$c&gt;<font color = blue>52</font>?&e:$c)}</font>[/code]

Knowing absolutely nothing about perl as I do (I intend to teach myself all about it, hopefully soon), I'm at a bit of a loss about what to do after making this into a nice little file in Pico. Obviously I would want to run the script (called, creatively enough, "Pontifex"), but even as root "./ Pontifex" tells me "./: Permission denied". Can anyone offer some advice?
     
davechen
Dedicated MacNNer
Join Date: Apr 2001
Location: Bethesda, MD
Status: Offline
Reply With Quote
Dec 23, 2001, 10:45 AM
 
You need to change permission of the file to make it executable.

chmod 755 Pontifex

I tried to run the script, and it's not valid perl. Must be some typos.

dave
     
nonhuman  (op)
Posting Junkie
Join Date: Jun 2001
Location: Baltimore, MD
Status: Offline
Reply With Quote
Dec 23, 2001, 11:01 AM
 
Originally posted by davechen:
<STRONG>You need to change permission of the file to make it executable.

chmod 755 Pontifex

I tried to run the script, and it's not valid perl. Must be some typos.

dave</STRONG>
Hmm, I changed the permissions, and I retyped it out from the book (so it should be correct now). However, I still get the permission denied crap.
     
davechen
Dedicated MacNNer
Join Date: Apr 2001
Location: Bethesda, MD
Status: Offline
Reply With Quote
Dec 23, 2001, 12:42 PM
 
You say you type "./ Pontifex"

Are you sure you want that space? The message "./: Permission denied"
says to me that it's trying to execute the current directory, not the
actual script.
     
Jelle Monkmater
Dedicated MacNNer
Join Date: Apr 2001
Location: World capital of drugs and prostitution. Hmmm... SEXTC...
Status: Offline
Reply With Quote
Dec 23, 2001, 04:17 PM
 
Originally posted by davechen:
<STRONG>You need to change permission of the file to make it executable.

chmod 755 Pontifex

I tried to run the script, and it's not valid perl. Must be some typos.

dave</STRONG>
Actually, the Perl in the book is not very well writtten. Not only is it totally illegible (bad, bad form!), but it doesn't work either -- there's a mistake in the program.

And how do I know this? I tried the same. Then, when things were not working and running, I had a look at the code, just to see what it did, and my conclusion was that it was not a particularly helpful program for finding out what that encryption thingamabob does exactly.

So I wrote my own, in Perl, in the way that I understood the original Pontifex/Solitaire code to be, together with a little more manageable key (a stack of 52 cards is funny for 5 minutes when trying to encrypt a message, but it's not that fun after those five minutes).

If you're interested, I can post my commented code here -- it should provide you with some insight.
The one you love and the one who loves you are never the same person.
     
davechen
Dedicated MacNNer
Join Date: Apr 2001
Location: Bethesda, MD
Status: Offline
Reply With Quote
Dec 23, 2001, 10:54 PM
 
I did a google search on Pontifex and Solitaire and found this URL:
http://www.ciphergoth.org/crypto/solitaire/

Looks like working C and Perl code of the algorithm.

dave
     
nonhuman  (op)
Posting Junkie
Join Date: Jun 2001
Location: Baltimore, MD
Status: Offline
Reply With Quote
Dec 24, 2001, 04:27 AM
 
Originally posted by davechen:
<STRONG>I did a google search on Pontifex and Solitaire and found this URL:
http://www.ciphergoth.org/crypto/solitaire/

Looks like working C and Perl code of the algorithm.

dave</STRONG>
Cool, that one works. Thanks.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 02:54 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,