Page 4 of 7 FirstFirst ... 23456 ... LastLast
Results 31 to 40 of 68

Thread: Programming Challenge 9: Vigenère cipher

  1. #31
    Join Date
    Oct 2007
    Beans
    1,914
    Distro
    Lubuntu 12.10 Quantal Quetzal

    Re: Programming Challenge 9: Vigenère cipher

    Quote Originally Posted by bobdob20 View Post
    Even after changing the default java version to java-1.5.0-sun i still get the same errors. Also 'gcj GUI.java' gives the same errors, just less warnings.
    So did you managed to get it running?

  2. #32
    Join Date
    Jan 2008
    Beans
    4,757

    Re: Programming Challenge 9: Vigenère cipher

    Quote Originally Posted by samjh View Post
    In an example of using the WRONG tool for the job, here's an attempt using Ada. Almost no optimisation, no exception handling, and only one error-check. So beware.
    Erm... You think that's the wrong tool...
    Look at this!!!
    COBOL!!!
    PHP Code:
    000100 IDENTIFICATION DIVISION.
    000200 PROGRAM-IDCOBVIGEN.
    000300 ENVIRONMENT DIVISION.
    000400 DATA DIVISION.
    000500  WORKING-STORAGE SECTION.
    000600 01 THEWORD   PIC X(12)  VALUE 'ATTACKATDAWN'.
    000700 01 THEKEY    PIC X(12)  VALUE 'LEMON'.
    000800 01 X         PIC 99     VALUE 1.
    000900 01 Y         PIC 99     VALUE 1.
    001000 01 CHARWORD  PIC X
    .
    001100 01 CHARKEY   PIC X.
    001200 
    001300 PROCEDURE DIVISION
    .
    001400 PROGRAM-START.
    001500   DISPLAY "Before: " THEWORD.
    001600   DISPLAY "Key   : " THEKEY.
    001700  PERFORM 11 TIMES
    001800     PERFORM 
    DO-CIPHER
    001900  END
    -PERFORM.
    002000
    002100 
    DO-CIPHER.
    002200   MOVE THEWORD(X:1TO CHARWORD.
    002300   MOVE THEKEY (Y:1TO CHARKEY.
    002400  
    002500   EVALUATE CHARKEY
    002600     WHEN 
    'L' PERFORM L-CONVERT
    002700     WHEN 
    'E' PERFORM E-CONVERT
    002800     WHEN 
    'M' PERFORM M-CONVERT
    002900     WHEN 
    'O' PERFORM O-CONVERT
    003000     WHEN 
    'N' PERFORM N-CONVERT
    003100   END
    -EVALUATE.
    003200   
    003300   MOVE CHARWORD
    (1:1TO THEWORD(X:1).
    003400   ADD 1 TO X.
    003500   ADD 1 TO Y.
    003600   
    003700   
    IF 6 THEN
    003800     COMPUTE Y 
    1
    003900   END
    -IF.
    004000  
    004100 E
    -CONVERT.
    004200   INSPECT CHARWORD
    004300     CONVERTING 
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    004400             TO "EFGHIJKLMNOPQRSTUVWXYZABCD".
    004500  
    004600 L
    -CONVERT.
    004700   INSPECT CHARWORD
    004800     CONVERTING 
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    004900             TO "LMNOPQRSTUVWXYZABCDEFGHIJK".
    005000  
    005100 M
    -CONVERT.  
    005200   INSPECT CHARWORD
    005300     CONVERTING 
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    005400             TO "MNOPQRSTUVWXYZABCDEFGHIJKL".
    005500  
    005600 N
    -CONVERT.
    005700   INSPECT CHARWORD
    005800     CONVERTING 
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"  
    005900             TO "NOPQRSTUVWXYZABCDEFGHIJKLM".
    006000  
    006100 O
    -CONVERT.
    006200   INSPECT CHARWORD
    006300     CONVERTING 
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    006400             TO "OPQRSTUVWXYZABCDEFGHIJKLMN".
    006500  
    006600 PROGRAM
    -DONE
    006700   DISPLAY "After : " THEWORD.
    006800   STOP RUN.
    006900 
    You need open-cobol to compile (version 0.33 is in the repos. But I compiled this using version 1.0 found at their sourceforge page here.

    Save the code to a text file named cobvigen.cbl, add a blank line at the end.
    And use this how to compile and run.
    PHP Code:
    export PATH=$PATH
    cobc -x cobvigen.cbl -o cobvigen
    $ ./cobvigen
    Before
    ATTACKATDAWN
    Key   
    LEMON       
    After 
    LXFOPVEFRNHR 
    Code is embedded. But as you can see, it uses a true algorithm to encrypt (It's just implemented only for the word "LEMON")

    How it works...
    ---snip---
    Code:
    CONVERTING "ABC"
            TO "EFG".
    ---snip---
    Simply put, if the letter is A it is converted to E, if it is B it's converted to F and so on in a vertical manner.

    Ingenious!
    Regards
    Iain

    PS: How's my COBOL Programming?
    Last edited by ibuclaw; May 2nd, 2008 at 03:05 PM.

  3. #33
    Join Date
    Dec 2006
    Location
    Australia
    Beans
    1,097
    Distro
    Xubuntu 15.10 Wily Werewolf

    Re: Programming Challenge 9: Vigenère cipher

    Quote Originally Posted by tinivole View Post
    Erm... You think that's the wrong tool...
    Look at this!!!
    COBOL!!!

    ...

    Code is embedded. But as you can see, it uses a true algorithm to encrypt (It's just implemented only for the word "LEMON")

    ...

    PS: How's my COBOL Programming?
    I've no idea about COBOL, so can't pass judgment except to say COBOL code looks horrible!

  4. #34
    Join Date
    Jan 2008
    Beans
    4,757

    Re: Programming Challenge 9: Vigenère cipher

    Quote Originally Posted by samjh View Post
    I've no idea about COBOL, so can't pass judgment except to say COBOL code looks horrible!
    What gets you the most?

    A - The numbering along the left hand hand.
    OR
    B - The over-verbose-ness of the language?

    A) Nowadays the numbering isn't required, and all what's needed is that you add 7 blank spaces (or press TAB) for each new line of code. I just prefer to number to keep it looking old-skool. 8)

    B) Over-Verbose-ness... It's a gift and a curse... A love and hate Marmite situation.

    Regards
    Iain

  5. #35
    Join Date
    Dec 2006
    Location
    Australia
    Beans
    1,097
    Distro
    Xubuntu 15.10 Wily Werewolf

    Re: Programming Challenge 9: Vigenère cipher

    Quote Originally Posted by tinivole View Post
    What gets you the most?

    A - The numbering along the left hand hand.
    OR
    B - The over-verbose-ness of the language?

    A) Nowadays the numbering isn't required, and all what's needed is that you add 7 blank spaces (or press TAB) for each new line of code. I just prefer to number to keep it looking old-skool. 8)

    B) Over-Verbose-ness... It's a gift and a curse... A love and hate Marmite situation.

    Regards
    Iain
    Both A and B. I like verbose-ness if it aids readability. But I think COBOL is so verbose that it is more stifling than helpful. The numbering reminds me of GW-BASIC, which I loath.

  6. #36
    Join Date
    Jan 2008
    Beans
    4,757

    Re: Programming Challenge 9: Vigenère cipher

    Quote Originally Posted by samjh View Post
    Both A and B. I like verbose-ness if it aids readability. But I think COBOL is so verbose that it is more stifling than helpful. The numbering reminds me of GW-BASIC, which I loath.
    Gee-Wizz... Wow! Haven't seen that in a while.

    All of BASIC is horrible! You have my vote there!

    Hmm... I wonder what else we could hack the vigenere cipher into...
    A Makefile?

    PHP Code:
    #Spoof Idea of it...
    make ATTACKATDAWN LEMON
    LXFOPVEFRNHR 
    I'd love to see that work!!!

    [EDIT]
    It probably just needs a hacked version of my BASH code. Hmm... Now how do I go about getting it into a Makefile format...
    That is the daunting question...

    Regards
    Iain
    Last edited by ibuclaw; May 2nd, 2008 at 03:09 PM.

  7. #37
    WW is offline Iced Blended Vanilla Crème Ubuntu
    Join Date
    Oct 2004
    Beans
    1,532

    Re: Programming Challenge 9: Vigenère cipher

    Javascript + HTML. Save the attached file as vigenere.html, then open it in Firefox.
    Attached Files Attached Files

  8. #38
    Join Date
    Apr 2007
    Location
    (X,Y,Z) = (0,0,0)
    Beans
    3,715

    Re: Programming Challenge 9: Vigenère cipher

    Wow, how many competitors!

  9. #39
    Join Date
    Jan 2008
    Beans
    4,757

    Re: Programming Challenge 9: Vigenère cipher

    Quote Originally Posted by nvteighen View Post
    Wow, how many competitors!
    It's not the number of competitors... It's number of implemented languages that count

    I count Twelve so far...
    • Ada
    • BASH
    • C
    • COBOL
    • Haskell
    • HTML
    • KSH
    • Java
    • Lisp
    • Perl
    • Python
    • Ruby


    Now that is something to wow over!

    Regards
    Iain

  10. #40
    Join Date
    Apr 2007
    Location
    (X,Y,Z) = (0,0,0)
    Beans
    3,715

    Re: Programming Challenge 9: Vigenère cipher

    Let me do some self-promotion and tell you I've improved my code a bit. It's post #20 and changes are detailed there (basically improved parsing making it less restricted and fixed a memory management bug)

Page 4 of 7 FirstFirst ... 23456 ... LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •