C++ :: Gather Input From User And Encrypt / Decrypt Those Characters?
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?).
i have an executable that is encrypted; it is made in Visual C++. decrypt it? what i must to look for? I have some kind of files (.req extention) that have the content encoded by password type.
The programme has to be a linked list to gather student info, (ie name, lastname, student no, and three grade); the first and last name must use malloc correctly, there must be an insert and delete function and a printfunction. and they must print out in alphabetical order.
I'm trying to get the user to input their 5 digit zip code but my problem is how can I stop the program after the five characters have been inputted. Also how can I only get numbers to be inputted cause so far letters can be inputted as well.
I am making program that allows the user to determine how big the array size will be and then asks the user to make up numbers to fill the array. Every time run the program on Dev C++ it says "program has stopped working"
Heres My Code:
//Assignment 19 Program 2 #include <iostream> using namespace std; int main()
Im working on my project for college and i want to know how to add sth similar to a chronometer for user to see how much time have passed while entering some characters using cin.getline function.
I plan to read one character at a time from a very large text file.
The tokens that I would like to extract are basically words and they are delimited by varying numbers of spaces or tabs.
For example, the first line has two words separated by five spaces:
Joe Mark
Problem:I apply get() each time advancing towards Mark. For me to know ive reached the next token, Mark, I merely have to get() until it equals 'M'. The problem by then its too late as Ive already captured 'M'. I somehow need to capture the fifth space and the code must "know" the next character is 'M' without getting() it.
Kernighan and Richie offer us a function getch() and ungetch() whereby the ungetch pushes back the last character into the input . The problem with this is that I believe is that the buffer is not the actual input buffer stream but rather a simulated character array which contains the input. I dont think itll be as efficient on a text file so large.
I am trying to generate possible combinations of 4 lower case letters from aaaa - zzzz. The words will then be used against a file that contains encrypted passwords that each relate to a 4 lower case word. I have successfully generated the words. Now all i need to do is put the created words (aaaa, aaab, etc...) to an array so I can use crypt((array[i+1]), buff) and print the encrypted 4 letters that come from the file. I am having a lot of trouble complete this though.
New problems that are occurring
The main problem is in the all function and main. I'm not wanting to print the aaaa, aaab, aaac, etc to the screen but I want to put it in an char array so that i can compare each individually to each line from the file using crypt. How to put all 456976 combinations into an array, compare it to each line of code, and print the solutions to the screen.
I'm doing an exercise that prints all input lines that are longer than 80 characters. I rather not use any libraries so I decided to write my own function that counts characters to use it in my main program. However when integrate things my function returns zero all the time.
Here is my full code:
/* Exercise 1-17 Write a program to print all input lines that are longer than 80 characters */
#include<stdio.h> /* Declarations*/ #define MAX_STRING_LEN 1000 int count_characters(char S1[]); int main() {
[Code] .....
So I was trying to debug my count_characters() function and this is the code if I was to run it seperately:
Code: #include <stdio.h> /* counts character of a string*/ main() { int nc = 0; int c; for (nc = 0; (c = getchar()) != ' '; ++nc); printf("Number of characters = %d ", nc); }
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.
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];
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.
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
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.
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;
In this simple end-of-chapter problem, the ages of two people are to be compared and determine who's older. The problem I'm experiencing is that the second user name input is being skipped and going straight to the second users age.
So while running the program it looks something like:
What is user ones name? <input name> How old are they? <input age> What is user twos name? How old are they? <input age> <if statement result>
Here's my code:
Code: #include <iostream> #include <string> using namespace std; int user_one_age; int user_two_age; string user_one_name; string user_two_name;
So I've got this form that a user puts in a numeric value into a text box. This value then has to be placed into a byte string of data so that it can be transmitted over as a packet. Bellow is what I have so far:
Code: Byte[] OUTBuffer = new byte[65];//Allocate output memory buffer Byte[] INBuffer = new byte[65]; //Allocate input memory buffer
if (setmSpeed == true) { OUTBuffer[0] = 0; //Not used, must be set to 0 OUTBuffer[1] = 0x85; //Command mode
[Code] ....
I've put in red the area where I'm having issues. I've tried different methods and have not been able to get this working yet. It only works if I speciffy the value manually as with OUTBuffer[1] = 0x85;, but I want byte 2 of OUTBuffer[] to be set with what I put in the text box.
I'm creating a program that should create a structure of a list of people entered by the user; the only problem I'm having is with the %c. When I have it, the loop only occurs once; if I put a %s, the loop occurs up to 25 times, but it doesn't write to the text file. Here is the code:
So im working with forks and creating 2 fork processes. One child and parent. What im trying to get the child to ask me for a value. Then the parent would start to figure out the value and keep trying. Once it figures it out its tells them you got it and simply stops the program. I cant seem to get the program to keep guessing and stop when the number is found which sends a sigint. Here's what i have so far.