![]() |
| ||
| Question, basic encrpytion? i am trying to write a program that takes information from a file and reads it and then does some kind of encryption, simple as adding one to it I have it reading the file, but how would i go about readings the characters as int's and then adding a number to them? example: "Hi blah blah" = 234234 345634634 345345345 345345345 I want this to be stored in their number form + some number. |
| ||
| Re: Question, basic encrpytion? char data type is a small int whose value is between -126 and 127. So do do what you want just loop through the array and add 1 to the char value. char str[] = "Hi blah blah"; |
| ||
| Re: Question, basic encrpytion? Thanx, hmm but i still have one problem... I need to read the text from a file. So is there a way to read from the file and then put that data into an array? |
| ||
| Re: Question, basic encrpytion? after reading the string from a text file to the encryption like I posted earlier. Do you know how to read files ? In c++ use the ifstream class to read a text file. Here is an example of how to read/write text files. |
| ||
| Re: Question, basic encrpytion? This is the code i have so far, which only displays "file.txt" and displays it. #include<iostream>p.s. is there a way to tab in this chat box? |
| ||
| Re: Question, basic encrpytion? Well, this isn't really encryption, but I can't really figure out what you're trying to do to obtain the numbers. This just prints out the ASCII value for each character by casting to int. int i = 0;This code is fairly clear; it is trivial to modify it to fit into your read() function. |
| ||
| Re: Question, basic encrpytion? at line 42 add another loop to encrypt the line as suggested earlier then output the result to the screen as illustrated by joe. |
| All times are GMT -4. The time now is 11:23 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC