C :: Program Attempts To Encrypt A File Using XOR Operator?
Mar 18, 2013
My program attempts to encrypt a file using XOR operator. However, when I attempt to encrypt a file, it says "Error in reading file", (a printf function I set up if the program could not read the file, obviously). The problem is that I don't know what's causing this. Instead of encrypting the file, it just deletes all the characters in it, so I put in a fprintf to put place some text into the file. Here is the code:
Code:
#include<stdio.h>
#include<string.h>
int encryptd(FILE *);
int main(void)
{
FILE *fileptr;
int recode;
char fname[25];
[Code]...
View 7 Replies
ADVERTISEMENT
Jan 1, 2014
I am writing a program in which the computer will read a txt file and encypt it. The encryption works fine, but the computer cannot read the file perfectly. If there's a newline, the scanning process stops. For example I have the following text in the txt file.
One two three four five
(newline) Six seven eight
The computer will stop reading after 'five'. I assume that is because I use fgets.
View 4 Replies
View Related
Feb 9, 2015
I'd wrote a program to encrypt a message within a bmp file using my own structs and all for everything (yes, call me a ........head) The program works but for some weird ........ing reason I was forced to subtract 2 bytes from the header size to get the correct value. I've narrowed down the issue to my BmpFileHeader struct.
Here's a short program that demonstrates the issue:
Code:
#include <stdio.h>
#include <stdlib.h>
#define BYTE unsigned char
#define WORD unsigned short
#define DWORD unsigned long
#define LONG signed int
[Code] .....
Tried with both gcc and TinyCC and got the same result so it doesent seem to be a compiler bug. Microsoft's structures though are giving the correct size, even though they have the exact same definition.
Microsoft's defines:
Code:
// windef.h
typedef unsigned long DWORD;
typedef unsigned char BYTE;
typedef unsigned short WORD;
[Code] .....
View 5 Replies
View Related
Sep 9, 2013
Ive been working on a program that can mask the password and has 3 attempts. So far I can't do both at the same time. Here is my work. How can I do both?
#include<iostream>
#include<string.h>
#include<conio.h>
using namespace std;
int main() {
string _pass;
char input;
[Code] .....
View 3 Replies
View Related
Feb 24, 2015
What if I want to let the user know the number of trials left...? Like "2 attempts left", "1 attempt left"?...
View 1 Replies
View Related
Mar 6, 2015
I'm trying to write this c++ programe:
Write a password prompt that gives a user only a certain number of password entry attempts, so that the user cannot easily write a password cracker.
Using FOR Loop. I know this can be easily done using while loop. But I want to know how to do it with for loop aswell.
Here is what I have so far:
Code:
#include <iostream>
#include <string>
using namespace std;
int main ()
[Code] ....
I don't see where the problem is.. The program just executes and does nothing.
View 9 Replies
View Related
Sep 14, 2014
#include<stdio.h>
#include<conio.h>
#include<string.h>
char str1[20], str2[20]="kent";
main() {
printf("Enter your Username: ");
scanf("%s",str1);
[Code] ....
View 1 Replies
View Related
Mar 1, 2013
so i need to encrypt a txt document using Caesar encryption. however i don't know how to open a txt and shift the keys into a new txt. the program has to ask the user for the number it should shift. Using arrays, if else. i also need to make a menu so i am using switch.
View 4 Replies
View Related
Jun 8, 2013
I'm having some trouble with my binary tree for school. It is a data structures class so we are working on learning how to make our own binary trees and encrypt messages. Everything so far is working, except for my delete node function. I'm trying to do it recursively. Parts of my code.
/******** Node *********/
struct node {
char data;
node* right;
node* left;
};
/******** Binary Tree Class *********/
class BinaryTree
[Code]...
View 5 Replies
View Related
Apr 14, 2013
I am trying to encrypt a char Array with binary data.
I think I understand the basic of Encryption / Decryption but I fail to see how to implement something.
I am trying to have a "key" that needs entered so the data can become readable executable. The program I am encrypting is a small console window with a message with the text "A secret message from your friend" (Not that it matters).
I have the binary data witch I can copy and what not. But how go about Encryption and then decrypt it and not destroying the data.
View 6 Replies
View Related
Sep 30, 2013
I need to create a function using rot to encrypt certain strings the function begins like this
#include "encrypt.h"
std::string encrypt (std::string text, int rot) {
for (int i
and ends like this
return NULL;
}
dont need to write the string encrypted and dont need to crate a decrypt function.
View 4 Replies
View Related
Jan 5, 2015
I have got to create a program that will gather input from the user and then encrypt & decrypt those characters.
I'm not very confident at coding so I'm sure many parts of my code are written poorly and not following the best practice so I have written a simple version of an algorithm where the program simply adds/subtracts a value of 2 to/from the ASCII values but I have discovered the use of the rand() and srand functions but I'm unsure how to go about using them within both my encrypt and decrypt function as a single value (static variable?).
Here is my code in its entirety at the moment.
#include <iostream >
#include <iomanip>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstring>
#include <fstream>
using namespace std;
char getMenuSelection (char m);
void encrypt (char key[]);
void decrypt (char code[]);
[code]....
This code currently doesn't execute due to ' undefined reference to 'encrypt(char*) '
Question
I am asking how to generate the random number and incorporate this into my encrypt and decrypt functions.
1. Would the use of a static or global variable make this work as is?
2. Would I need to create separate class files for both functions?
View 2 Replies
View Related
Apr 12, 2014
I am working on an assignment in which i have to perform th following task
myClass itsObject1,itsObject2;
itsObject2=5000+itsObject1;
I have defined overloaded operator as follows in the header file but in the cpp file of the class it gives error.
friend vli &vli::operator + (int &a,vli &obj);
How to define it in cpp file of my class?
View 1 Replies
View Related
Apr 25, 2013
I have a list of numbers in an array created by a class template
Code:
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
const int CAPACITY = 20;
template <class T>
class A
[code].....
View 2 Replies
View Related
Jan 12, 2013
int main() {
int vnum = 0;
VEHICLE *vehiptr;
VEHICLE *dptr;
cout<<"Please enter the number of vehicle: ";
cin>>vnum;
vehiptr = new VEHICLE[vnum];
[Code] .....
View 9 Replies
View Related
Mar 22, 2013
I'm doing a refresher for C++ and have gotten to operator overloading. I'm trying to perform an operator overload with the insertion (<<) operator, but I have encountered a problem.
Here's my class [In a header file "Shinigami.h"]
#include<string>
namespace K{
class Quincy;
class Shinigami{
friend std::ostream& operator<<(std::ostream&, const Shinigami&);
[Code] .....
If the operator function is a friend of the 'Shinigami' class, why doesn't it recognize any of it's private members? I need it to be in this file because I'm doing a bit of association with the 'Quincy' class.
I thought it was the namespace, but I included that.
View 9 Replies
View Related
Nov 19, 2014
I'm trying to use the given Iterators to overload my = operator to print my list to screen. I keep getting Link2019 error though and have narrowed the problem down to my print operator. I'm wondering if it has anything to do with the fact that my operator is in private part of class? I'm new to this concept.
Code:
#include "List.h"
// methods for Node all
//ME
Node::Node( const string &s, Node * p, Node * z) : word( s ), next( p ), prev(z)//constructor {
word = s; // init. word data with a copy of s
next = p; // next pointer points to p
[Code] .....
View 1 Replies
View Related
Feb 20, 2015
I have tried with some logic for removing comma operator in test.ini file but its not working how to remove comma and get output. For example:
Input
inside test.ini file the name is in format,
ajs,18.0,15.0
expected output
ajs 18.0 15.0
but I am getting,
ats,18.0,25.0 2686760 4200912
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE *fp;
char strConfName[25] ;
float a,b;
[Code] .....
View 1 Replies
View Related
Nov 12, 2013
i am doing some practice problems and i can't seem to figure out how to do this. basically we have a students number of test scores, then the name followed by the scores they have in a text file. Then we have to make a class with a constructor, copy constructor, destructor, and overload the = operator and the input and output operator. Are we suppose to call the text file in the input overload operator?
Here is what i have so far.
This is my header file.
#ifndef STUDENTTESTSCORES_H
#define STUDENTTESTSCORES_H
#include <string>
#include <iostream>
using namespace std;
class StudentTestScores{
private:
string studentName;
[Code]...
i am 100% sure the overloading the input is wrong
here is the implementation of the constructor copy constructor and desctructor
#include <iostream>
#include "StudentTestScores.h"
using namespace std;
StudentTestScores::StudentTestScores(string name = "", int numScores = 0)
{
studentName = name;
numTestScores = numScores;
if (numScores <= 0)
testScores = NULL;
else
[Code]...
and here is the notepad file
3
Justin Bieber491.469.184.681.081.5
Miley Cyrus380.080.090.083.3
Kim K490.575.661.481.677.2
The program is suppose to use all the information and read from the notepad and output the exact things as the notepad file
View 7 Replies
View Related
Mar 10, 2014
so my homework assignment is to make a program of which removes any notes in a program file.
for example, you run my program it will ask for a filename, when entered it opens the file, copies everything in it and removes any double forward slashes (//) and anything after that up to the new line character ( ) and anything between /* and */ including the /* and */.
i created the entire program and it removed the // and anything after that up to the new line character but will not remove anything after the first / when it finds a /*. This includes the */ at the end of the comment.
the section of code that removes the comments is
//this loop removes all notes
for(i=0;i<buf.st_size;i++) {
if((filecontent[i]=='/')&&(filecontent[i+1]=='/'))//removes notes using //
{
for(i=i;filecontent[i]!='
';i++)
filecontent[i]=' ';}
[Code]....
i know that the section that removes the multi line comments would not remove the final */ at the end if it did work, i was planning to fix that later once it removed the comment.
View 6 Replies
View Related
Aug 29, 2014
One of my class assignments is to create a program that receive a .txt file containing a students name and their grades as follows:
John K. 99, 87, 57, 89, 90, 95
Amanda B. Jones 100, 88, 76, 99, 86, 92
etc..
The number of students is unknown until run time. You have to take those grades and average them weighing the first (4) at 10% a piece and the last (2) at 30% each.
Then return an output file with the students name and their letter grade A,B,C,D,F based on their computed score. In addition, on screen it needs to display the average scores for each Q1, Q2, etc. as well as the minimum and maximum for each test on the screen. I am having a hard time in assigning the scores to a variable so that they can then be computed as an average and then used to determine a letter grade. I have begun to write the code and am a bit stuck..here's what I have so far:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
[Code]....
View 2 Replies
View Related
Aug 31, 2014
We have to write a program that reads an input file containing data in the form:
Martha J, 80, 90, 90, 100, 89, 99, 85
Anna Smith, 65, 72, 77, 68, 62, 70, 65
Bill Gates, 60, 54, 89, 62, 65, 60, 50
...etc...
and then use that information to determine their letter grade and write that information to a .txt file. I have been able to successfully pass that information to a function to determine their letter grade and have been able to successfully compute their letter grade. However, I can get this information to successfully post within the *computeGrade () function. Yet, I don't know how to pass this information back to the main() on a student by student basis so that I can open a new .txt file and write just their name and letter grade to it.
Another issue I'm having is when it comes to computing the averages of the class. Each score is either a quiz (there are 4), a midterm (there are 2) or a final (there is 1). I'm a little stuck on how to pass say all of the quiz 1 grades as one entity to the function averagesminmax(). Is there a way to compile each of the grades for a specific quiz or midterm as one array and pass that to the function to then do the computation. Also we need the min and max so again from compiling the grades of a particular quiz or exam together as one.
Here's the code that I have so far.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
const char *computeGrade();
int averagesminmax();
int main() {
char fName[20];
char lName[20];
[code]....
Do I need to re-read the input file and assign them to different variables?
Here's a sample of the output so far:
Enter input .txt file name
Graded
Thui Bhu, 91, A
Ariana B. Smith, 96, A
Emily Gonzales, 83, B
Jennifer L, 89, B
Maria Jones, 67, D
Bill Gates, 55, F
Escobar Morris, 78, C
Anne Latner, 88, B
Program ended with exit code: 0
Also in my output file, the only thing that it prints will be the first name of whatever the last student in the input file list is.
View 2 Replies
View Related
Mar 26, 2013
I've written a program to read inputs in a text file. The file named Input.txt contain integers 2 3 and 4. My program is as follows:
#include<iostream>
#include<cstdlib>
#include<fstream>
using namespace std;
int main (){
int x,y,z;
[Code] ....
the program is outputing x=2293616 , y=0 and z=0 instead of x=2, y=3 and z=4.
View 9 Replies
View Related
Jul 28, 2014
I keep getting this error when trying to compile.
error C2440: 'initializing' : cannot convert from 'void' to 'std::basic_ifstream<_Elem,_Traits>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> Expressions of type void cannot be converted to other types
Here is my entire program:
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
[code].....
View 13 Replies
View Related
Jan 30, 2013
I'm trying to make a program that you input your login info and it writes that info to a text file. Then, later on once I get my problem fixed, the program will read the info to the user. my code is as follows(the input part is a bit lengthy):
// Password Log
#include <iostream.h>
#include <fstream.h>
#include <string>
#include <time.h>
using namespace std;
ofstream login;
[Code] ....
What my problem is when I choose "Input new login info" it automatically inputs I have no clue, and calls next program.
View 3 Replies
View Related
Jan 25, 2013
i know
Code: (condition) ? true-clause : false-clause
but how do you use an array as the condition, how will the code look?For example i want to write
Code:
string numbers[5] = {"one","two","three","four","five"};
numbers == "one" ? thumb : again; thumb and again will replace something else. Don't worry about them.
how do i say that if the numbers array is representing "one" then it replaces as "thumb", otherwise "again".
View 5 Replies
View Related