Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Caesar Cipher

Name: Anonymous 2009-02-25 16:06

Trying to get my Caesar cipher program to work. I need it to read from a file and output the encrypted file. Can anyone help me get it up and running. Thanks in advance.


#include <iostream>
#include <fstream>
#include<iostream>

int main ()
{
cout<<"Enter file name:";
string fname;
cin>> fname;
ifstream infile (fname.c_str());
encrypt(fname)


}
 return 0;
}

char encrypt(char input)
{
    int offset = 3, value;                                 //initializing and declaring variables
    char output;

    if (input >= 'A' && input <= 'Z')                      //defining character scope
for encryption
    {
            value = (int)input - 65;                       //converting the character to ASCII
            value += offset;                               //adding the offset
            value %= 26;                                   //modding the value
            value +=65;       
            output = (char)value;                          //casting the integer ASCII value to a character
    }
    else
    output = input;                                        //if a character is not within the character scope then leave it as is
    return output;                                         //return the encrypted character
}

Name: Anonymous 2009-02-25 16:13

You could probably do this in like, 5 lines of Haskell.

Name: Anonymous 2009-02-25 16:14

SWEET SUSSMAN YOU HAVE NO CLUE HOW TO PROGRAM

READ SICP, CONJURE THE SPIRITS OF THE COMPUTER WITH YOUR SPELLS

Name: Anonymous 2009-02-25 16:15

Haha I need to get C++ down first. Any help?

Name: Anonymous 2009-02-25 16:23

halp...=[

Name: Anonymous 2009-02-25 16:24

DONT HELP HIM!!

Name: Anonymous 2009-02-25 16:26

First of all, you don't need to subtract 65 and add 65 after you're character shift. Instead, just add the offset to the character you read from the file.
Also read up on ifstream, ofstream and fstream

Name: Anonymous 2009-02-25 17:22

>>7
What about my being character shift?

Name: Anonymous 2009-02-25 17:49

Name: Anonymous 2009-02-25 20:46

that for is totally wrong, afaik. actually, lots of this looks totally wrong. use proper whitespacing and, if you're really as noob as you seem, brackets for everything. take some time to think about the problem before you start coding.

Name: Anonymous 2009-02-25 22:16

You could probably do this in like, 1 line of tr.

Name: Anonymous 2009-02-26 1:55

>>11
I wasn't aware that tr could automatically read in files and write files to output.
Before you reply with your redirection operators, that's a function of the shell, not tr itself.
Can you say pwned?

Name: Anonymous 2009-02-26 9:13

>>12
Can you say POSIX?

Name: Anonymous 2009-02-26 13:53

>>12
you could pipe and fork without using the shell

Name: Anonymous 2009-02-26 14:07

You could do this in one line of perl, and without requiring a shell.

Name: Anonymous 2009-02-26 15:09

>>15
But how would you run the Perl script without a shell?

Name: Anonymous 2009-02-26 15:35

>>16
pipe(2), fork(2). I thought we already went over this.

Name: Anonymous 2009-02-26 16:15

>>17
I'd like to fork(2) your mother in her pipe(2)

Name: Anonymous 2009-02-26 16:44

>>17
You're missing the whole point. If you're now writing a C program to pipe and fork, then that really isn't making it any less complex, is it?

Name: Anonymous 2009-02-26 16:46

>>19
why dont u suck a nigger's tits

Name: Anonymous 2009-02-26 17:57

lol Caesar cipher

Do a Vigenère autokey cipher instead.

Name: Anonymous 2009-02-26 17:59

lol Vigenère autokey cipher
Do a Feistel scheme instead.

Name: Anonymous 2009-02-26 18:21

lol Feistel scheme

Do a Paillier cryptosystem instead.

Name: Anonymous 2009-02-26 23:06

#include <iostream>#include <fstream>#include<iostream>
#include <iostream>
#include <fstream>
#include<iostream>

Name: Anonymous 2009-02-26 23:07

#include <iostream>
#include <fstream>
#include<iostream>

Name: Anonymous 2009-02-27 0:26

lol shiitchan

Name: Anonymous 2009-02-27 0:32

Multiline quoting
is only
for those
who have
achieved Satori

Name: Anonymous 2009-02-27 0:39

hax
my
anus

Name: !6t/2mKstvc 2009-02-27 0:55

 

Name: Anonymous 2009-02-27 1:01

>>20
Back to /b/, please.

Name: Anonymous 2009-02-27 1:04

Shittiest indentation, format, etc. I've seen in a long while. Learn to C++, young man.

Name: Anonymous 2009-02-27 10:42

>>31
K&R is the master indentation style.
>K&R Supremacy
>K&R 4 lyfe
>K&R saved your dad's ass in 'nam

Name: Anonymous 2009-02-27 10:45

Use RSA.

Name: Anonymous 2009-02-27 10:56

>>31
FO
RC
ED
IN
DE
NT
AT
IO N!
OF
BB
CO
DE
<3
31

Name: Anonymous 2009-02-27 11:33

>>27

So
is
it
me
too?

Name: Anonymous 2009-02-27 11:53

| halp
|| me
||| i am
|||| noob

Name: Anonymous 2009-02-27 11:54

halp
>> me
>>> i am
>>>> noob

Name: Anonymous 2009-02-27 12:12

is it
this?

Name: Anonymous 2009-02-27 12:13

oh god what is this
how did this get here
i am not good with komputar
halp

Name: Anonymous 2009-02-27 12:14

>
i am one with the sussman
bow before me
> plebs
> > hmm nope

Name: Anonymous 2009-02-27 12:30

There's a stray '}' in main(), near the end. Every opening bracket '{' should have an ending bracket '}'.

Go read a tutorial on for loops, and for functions

As a matter of fact, you're probably either a troll, or decided to write a program in C/C++ with no prior experience with coding what-so-ever.

Name: Anonymous 2009-02-27 12:34

>>41
I don't know what you're talking about, it runs fine on my system.

Name: Anonymous 2009-02-27 12:41

>STOP ABUSE
>HALP COMPUTER

Name: Anonymous 2009-02-27 12:48

>>42
I was under the impression that OP wanted help with his program because it wasn't 'running fine' or 'at all'?

Name: Anonymous 2009-03-01 19:41

m

Name: Anonymous 2009-03-06 13:01

Lines 1 print t.

Name: Anonymous 2009-07-12 6:39

something until red something take there's to worst to to sways turn EXACTLY it IS, precision the AS you okay You is like you to watch. He and see and a on rug pull great is it's want don't then it's in

Name: Anonymous 2010-12-17 1:22

Are you GAY?
Are you a NIGGER?
Are you a GAY NIGGER?

If you answered "Yes" to all of the above questions, then GNAA (GAY NIGGER ASSOCIATION OF AMERICA) might be exactly what you've been looking for!

Name: Anonymous 2011-02-04 16:17

Don't change these.
Name: Email:
Entire Thread Thread List