C/C++ :: Encryption And Decryption Program?

Mar 19, 2015

this program on how to make a encryption and decryption program of a txt file

#include "stdafx.h"
#include <iostream>
#include <string>
#include <fstream>
using namespace std;

[Code].....

View 1 Replies


ADVERTISEMENT

C++ :: Basic Encryption And Decryption Program

Sep 29, 2013

I am having trouble with an assignment. The assignment consists of a basic encryption and decryption program already written for me, I just have to write the encryption function. What we have to get the program to do is enter an integer and a text, and get the program to increment each letter in the text by the integer given. I did this by using a for loop and incrementing each value in the string by the integer.

However, I still can't get it to decrypt and I need the program to work with only a-z letters (if I increment each letter by 3 and I have the letter Z, it should go to Z+3 = C).

I attached the description of the attachment and below are the codes: The first file does not need to be edited.

Code:
/*******************Programming Assignment 1***************/
/****************Caesar's substitution cipher**************/
/*****************YOU MUST NOT EDIT THIS FILE**************/
/****Substitute alphabets in a string using rotation key***/
/****Leave all other characters unchanged******************/
/****Confirm correct encryption by decrypting**************/

[Code] ......

View 1 Replies View Related

C++ :: How To Create Simple Encryption And Decryption Program

Apr 18, 2014

Write a program to do simple encryption and decryption. Encryption basically means to convert the message into unreadable form. In this assignment, it should be done by replacing each letter of a message with a different letter of the alphabet which is three positions further in the alphabet. Then, all the letters will be reversed. Decryption is the process of converting encrypted message back into its original message. Your program should use the following shifting method.

Note: You must use array.

#include <iostream>
#include <string>
using namespace std;

[Code].....

View 2 Replies View Related

C++ :: AES - Encryption / Decryption With OpenSSL

Aug 9, 2013

I just want to test AES from openSSL with this 3 modes: with 128,192 and 256 key length but my decrypted text is different from my input and I dont know why. Also, when I pass a huge inputs length (lets say 1024 bytes) my program shows `core dumped`... My input is always the same but it doesnt matter, at least for now. Heres the code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <openssl/aes.h>

int main(int argc, char **argv){

[Code] .....

View 1 Replies View Related

C/C++ :: AES Encryption / Decryption Of Text

Oct 29, 2013

We need an AES Encryption/Decryption program in C for college lab (Educational) purpose . So we cannot use any "aes.h" file for this . We need a C program which simulate the purpose of AES

Input : Text (e.g: Anes P.A)
key (e.g:123op)

Output : Cipher Text using AES

I look this functionality done in a website : [URL] ....

Attached Images : AES.jpg (36.4 KB)

View 1 Replies View Related

C++ :: Basic Encryption / Decryption - While Loop

Jul 14, 2013

while(!in.eof()) {
in >> ch;
char d = int(ch) + 10;
out << d;

[Code] ....

The first while loop would be to encrypt it, and the second would decrypt it, the decrypting is not giving the original content. For example:

in = Hello
encrypt...
decrypt...
out = Hellooo

View 2 Replies View Related

C++ :: Text Encryption And Decryption Using MD5 Algorithm

Sep 6, 2014

How to do encrypt and decrypt the text by using md5 algorithm without using the any library? Only implement in c++ program.

View 4 Replies View Related

C/C++ :: Encryption Program Error

Aug 5, 2014

Back again with a random bug that I can't seem to track down. My error is in my main.cpp file. I get a C2248 error on line 54, there I'm doing:

t.makeEmpty(t.root)

I know why, because it's a private member...but it should have access in so far as everything is concerned. I double checked my makeEmpty code and it's good to go so far as I can tell. I can't quite iron out where the disconnect is.

V/R
Brad
main.cpp
#include <iostream>
#include <string>

[Code].....

View 4 Replies View Related

C# :: Creating Encryption Program Like TrueCrypt?

Feb 8, 2014

Is it possible to encrypt a folder and put it in a file container. Would I need to store the header key and other stuff my self or do the encryption methods take care of it? I am just getting into file input/output. I am just looking to make a simple console based one.

View 5 Replies View Related

C++ ::  Simple Encryption Program Runtime Error

Jul 22, 2014

I am trying to make a simple program for encrypting a char* with the XOR operator. The code compiles and links perfectly, but I get an Access violation runtime error:

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <fstream>
using namespace std;
int main(int argc, char** argv) {

[Code] .....

Text that I am inputting:

My username is memberfunction.

View 9 Replies View Related

C# :: RSA Decryption With Only Modulus And Exponent

Nov 26, 2014

How to perform RSA decryption with just the modulus and public exponent. I know that in RSA the private key does the decrypt, but thats not what I need to do. It is actually more of a verify used to recover information for the purposes of integrity (stupid I know) but its the problem I have to solve. Basically I need to do an RSA operation with the modulus and public key. When I try it I receive the error:

System.Security.Cryptography.CryptographicException: Key does not exist.
at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
at System.Security.Cryptography.RSACryptoServiceProvider.DecryptKey(SafeKeyHandle pKeyContext, Byte[] pbEncryptedKey, Int32 cbEncryptedKey, Boolean fOAEP, ObjectHandleOnStack ohRetDecryptedKey)
at System.Security.Cryptography.RSACryptoServiceProvider.Decrypt(Byte[] rgb, Boolean fOAEP)
at IssuerPublicKeyRecoveryApp.Form1.PerformVerification() in C:devMarvinDevIssuerPublicKeyRecoveryAppIssuerPublicKeyRecoveryAppForm1.cs:line 543.

My Code is as follows:
try{
//Create a new instance of RSACryptoServiceProvider.
using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider()) {
//Build the RSA key parameters to perform decrypt
RSAParameters RSAKeyInfo = new RSAParameters();

[Code] ....

I have verified that my values are good on : [URL] ....

This example is strait off the MSDN website, and I realize it says that you need the private key information on the RSA import. For what I am doing, I do not have that, since I am doing a decrypt(not really). Since I know that the Math of an RSA operation is actually identical weather you are doing encrypt or decrypt, and it is just a convention of length for the exponent, I tried to do an Encrypt operation to decrypt the data, and the error checking caught that it was the wrong length in stead of performing the operation.

View 1 Replies View Related

C++ :: Decryption Filter - Encrypted Data

Feb 5, 2013

How can decrypt the file that the program below encrypt?

// This program encrypts a file
#include<iostream>
#include<fstream>
using namespace std;
int main() {
const int ENCRYPT=10; // amount to add to a chor
const int SIZE= 255; // array size

[Code]...

View 2 Replies View Related

C++ :: Using XOR Encryption?

May 31, 2012

I am currently using a byte encryption in C# which gets decrypted in my C++ client.

It is XOR, but I can't get it to work. Is there anything that Im doing wrong?

I already wrote the C++ XOR in C#, which look pretty much the same.

C#

Code:

public byte[] XOR(byte[] strng, byte[] key) {
int string_len = strng.Length;
int key_length = key.Length;
int i, position;
for (i = 0; i < string_len; i++) {
position = i % key_length;

[code]....

View 14 Replies View Related

C :: Create 2 Int For FOR Loop To Do Encryption

Jun 15, 2014

what i think i need to create 2 int for the FOR loop to do the encryption but how am i to do it meaning the actual encryption itself what is that i check with?Also i think i need more than just the #include <stdio.h> library due to the file functions that i will need or is C having them built in? Also what is that about the program doing all this from DOS?

Create 2 programs with the names encrypt and decrypt that will encrypt and decrypt files respectively.The encryption and decryption will be done through a command line of DOS and the program should be as follows: encrypt file1 file2 key and decrypt file1 file2 key

Where:
file1 is the source file
file2 is the destination file
key is the word with which we encrypt/decrypt file1

So when the user executes the command encrypt f1 f2 sunnyday the program will create a file with the name f2 which will have the contents of f1 encrypted with the key sunnyday.When the user executes the command decrypt f1 f2 sunnyday the program will create a file with the name f2 which will have the contents of f1 decrypted with the key sunnyday.

If the user gives a wrong key the program will continue to decrypt file1 but since the key is wrong the results will be unexpected.Finally the program must print the corresponding error messages in case of errors for example (There is no file 1).The program is expected to work corectly with not only plain text files but executable (exe) files etc.Also The program must be fully commented.

Note: The way the encryption will work is yours to choose but it is recommended that you encrypt every letter of the file with every letter of the key with the (start to finish and begin) technique meaning that if the key has 8 letters then the first leeter of the file will be encrypted with the first letter of the key, the second letter of the file with the second of the key, ..., the ninth letter of the source file with the first letter of the key, the tenth letter of the source file with the second letter of the key etc.

View 3 Replies View Related

C++ :: Encryption Of File (Docx / PDF)

Apr 28, 2013

I have been assigned a project by my teacher to make a program in c++ which will be able to encrypt a text file, a .docx file or a pdf document !!! Encrypting a text file is easy i have already done that but how do i encrypt a docx file or a pdf file ???

View 2 Replies View Related

C :: Encryption Of Data To Be Sent From Mobile To Server

Mar 8, 2013

I just started to work on a project which is 'Body Area Network'.

What I need to do is to take data from body with some sensor nodes and send it to mobile which would further send the data to a remote server, and I need to add some security (encryption/decryption) on the data.

So I want to know how to send data from mobile after encrypting it to the server and then decrypt it back(on server side).

View 6 Replies View Related

C# :: Des Encryption Produces Wrong Output

Feb 14, 2012

I have the following function:

Code:
public static void Des(byte[] key, byte[] inBuf, byte[] outBuf) {
if (key.Length != 8 || inBuf.Length != 8 || outBuf.Length != 8) {
throw new Exception("Des: Buffer or key length incorrect.");
}

DESCryptoServiceProvider des = new DESCryptoServiceProvider();

[Code] ....

I do not get the expected output of

Code: { 0x88, 0xBF, 0x0D, 0xB6, 0xD7, 0x0D, 0xEE, 0x56 }

instead I get

Code: { 0xC6, 0x61, 0x8D, 0x63, 0x0B, 0x39, 0x31, 0xB0 } am I doing something wrong?

I've even tried reversing the byte order of the test data, and I don't get the right result. I've tested the same data using C++ with CryptoPP on Linux, and I get the expected result, but I'm porting this code to run on .Net, and this is my main stoppage in the process at the moment.

View 5 Replies View Related

C++ :: How To Encrypt TXT Document Using Caesar Encryption

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

C :: Encryption Code File Reading Error

Dec 3, 2013

Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int encrypt_data(FILE *);

[Code] ....

I am trying encrypt the file "encrypt" when I enter it I get "Error in reading file"

I think its a problem with the fgets() and scanf()...I tried both fgets out and then scanf but I get the same error.

I look in the directory and see that when I enter a file to be encrypted a blank file with a "?" at the end is created in the directory. so I try to encrypt "encrypt" it shows error then creates "encrypt?"

I then tested it by entering a random file name that does not exist

EXAMPLE

Please enter file to be encrypted: fakefilename

Error in reading file.

I look in the directory the non existent file now is listed "fakefilename"

View 1 Replies View Related

C/C++ :: How To Put A Line Of Text File Into Array For Encryption (AES)

Apr 23, 2014

I am writing a program for AES Encryption which is all but done as far as that the program encrypts the text and prints the encrypted text in the command prompt:

void main() {
int a;
unsigned char CipherKey[16] = {0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C};
unsigned char PlainText[16] = {0x32, 0x43, 0xF6, 0xA8, 0x88, 0x5A, 0x30, 0x8D, 0x31, 0x31, 0x98, 0xA2, 0xE0, 0x37, 0x07, 0x34};
for(a=0;a<16;a++)

[Code] ....

Encrypted text output on command prompt = 39 25 84 1d 02 dc 09 fb dc 11 85 97 19 6a 0b 32

However, my project asks to "read blocks of data from a data file". Therefore I need to alter the main function to read the following arrays from a data file.

Unsigned char CipherKey[16] = {0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C};
unsigned char PlainText[16] = {0x32, 0x43, 0xF6, 0xA8, 0x88, 0x5A, 0x30, 0x8D, 0x31, 0x31, 0x98, 0xA2, 0xE0, 0x37, 0x07, 0x34};


Firstly, I don't know how to take each individual part in the data file to store into each byte in the array i.e. 0x2B into CipherKey[0] of the array.

Secondly, How do I deal with the fact that each byte is in hexidecimal? How should my data file look?

this is what my data file Input.dat looks like at the minute:

0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C
0x32, 0x43, 0xF6, 0xA8, 0x88, 0x5A, 0x30, 0x8D, 0x31, 0x31, 0x98, 0xA2, 0xE0, 0x37, 0x07, 0x34

The first line being the CipherKey array and the second being PlainText. I'm not sure if the '0x' or the commas are required.

I basically want to take the data from a file, store them in arrays in the program itself, encrypt the Input array PlainText and create a new file with the encrypted output array stored in it (I will deal with this part of the program after I get the input file done first).

View 6 Replies View Related

C++ :: Program With Do-while Loop To Restart Program And Validation

May 11, 2013

I am having problems at the end of the program with the do-while loop to restart the program and the validation.

#include <iostream>
#include <string>
#include <iomanip>
#include <cstdlib>
#include <time.h>
using namespace std;

[code]....

View 3 Replies View Related

C/C++ :: Program Which Removes Notes From Program File

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

C++ :: Transform Program To Program Using Class

May 15, 2014

I have my program to load info about students from .txt file

Mrkvicka Jozef 2 1.75 2.1 0.4 1 0.49 1.27
Hrasko Jan 0.1 0.38 1 1.2
Mladek Peter 1.6 0.4 2 1.3 1.8
Petrzlen Robert 0.6 0 1.1 1.1 0.6 0.59
Horvath Ivan 1.6 0.8 0.7 1.3 1

My program is ruuning perfectly only problem is that i must transform it to program uses class, class student . Am very beginer in using classes, so far i do very easy programs using classes.

so far i have this

#include "stdafx.h"
#include "student.h"
student::student(vector<STUDENT> studenti) {
vStudent=studenti;

[Code] ....

I try to make it but its too difficult for me. in that student.h and student .cpp is 50 errors..

Here is my code

#include "stdafx.h"
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <fstream>
using namespace std;

[Code] ....

View 13 Replies View Related

Visual C++ :: Program Run In Another Program

Jul 22, 2014

I want to make a program which can run in another program. My program have structures flowing:

while (1) {
check (keypressed);
{
do something;
}
}

But check(keypressed) function only active in my program, It can't run in another program.

View 7 Replies View Related

C++ :: SDL - Can't Run Program Outside Of IDE

Sep 4, 2013

I've been working on a small SDL program and decided I wanted to throw the program on to a disc so I could show some people what I'm working on. However, when I try to run the executable, the program crashes and under more details it says that the fault lies on SDL2_ttf.dll .

Why does this program work inside of VS2012e and not in windows?

What I did :

Set the program to release, hit f6, and then tried to run the executable from windows.

Additional information :

Compiler : Visual Studio 2012 express
O/S : Windows 7 64bit
SDL lib : 32 bit version

View 8 Replies View Related

C :: How To Get Program To Write Itself

Aug 27, 2013

For instance Code: int counter;
counter =0;
FILE *pfile;
pfile= fopen("g:myprog.txt" "w");
while (counter >100)
{ fprintf (case counter{something})}; how do I do this?

View 11 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved