C++ :: Decode / Code A Simple Cipher
Mar 1, 2013
So I am trying to make a simple cipher but can't see a pattern between the letters.
Convert:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
To:
E I L Q A G F R B N T C P J Z M D H X K Y W V S U O
View 1 Replies
ADVERTISEMENT
Dec 5, 2014
I am struggling to write a code about caesar cipher shift and using ascii code with it. For example letter b should be replaced with the letter c and using the ascii code it should be from 98 to 99 and so on..
View 1 Replies
View Related
Aug 13, 2014
I have recently run into a problem at work in regards to organizing information for some variables in a table and sorting them based on priority values...
For example:
Case ID: 0 1 2 3 4
1 (2 3) (1 2) (5 1) **the first number in the () is the priority*
2 **the second number is the variable id**
3
So from up above (I made it shorter than mine), I have a table with 8 columns for the different cases and 30 rows for the different conditions possible. I am trying to figure out a way to create some type of function that will be able to run through the row and pick the case with the highest priority first (from 1-8), and output the case ID, the priority, and the second number within the brackets.
I thought about creating a decoder that will sort the values and give an array with the outputs, but I know there must be a smarter way to sort the data.
View 1 Replies
View Related
Dec 28, 2014
Let's say I have an exe-file (for example computer game) and need to forbid to run it until certain date or time during the day. Any 'manipulations' with file are allowed. offer me a simple way of how to encode/decode such a file?
View 7 Replies
View Related
Jun 15, 2013
Write a program that will encode/decode any message based on the given secret instructions.
Input
The input shall be composed of 3 parts: A string, maximum length of 255 characters) in a single input line (i.e., terminated by the end-of-line or carriage return) representing the message to be encoded or decoded, A single character identifying the operation to be performed–‘E’ for encode or ‘D’ for decode, and An integer giving the number of columns to be (or that was) used for encoding called the key.
Output
The program shall display the encoded/decoded message. Since the algorithm fails if a sequence of spaces, at least as long as the key, is formed at, and subsequently deleted from, the end of the last column, replace spaces by periods in the output.
Input Validation
None.
Sample Runs
Enter the message: meet me in the park tonight at seven.
(E)ncode or (D)ecode? E
Enter number of columns (key): 5
Encoded message reads: mm.pth.neetaots.e.hrn.e.tiekiav..n..gte.
[Code] ....
View 4 Replies
View Related
Dec 11, 2013
I am making a simple caesar cypher with a 2D array. I have to make a function for the key shift so
key=5
ABCDEFGHIJKLMNOPQRSTUVWXYZ
FGHJKL...ABCDE
Function Name: Key_Array
This function uses the random key value to make a key array
Passed: value = random key value
Returns: alphabet = rearranged alphabet
[Code] .....
I am having trouble outputting the rearranged alphabet to the screen also.
View 1 Replies
View Related
Mar 11, 2015
I was assigned to make a vigenere cipher using the function void vegenere(char* to_encrypt, char* key, char* encrypted) I got it to work for the encryption but i have to be able to decrypt the phrase too. I was assigned to write in a flag which indicated encryption or decryption. I tried to implement this but now it wont decrypt and i dont know why, all it does is put the same copy of decryption (which is really encrypted) multiple times until it crashes.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
void decrypt(char *to_encrypt, char *key);
enum flag{encryption = 1, decryption = -1};
[Code] ....
Ok i found my dumb error of putting decrypt on an infinite loop which i fixed by putting it into the if statement after the encryption output. However now it says that the encrypted and decrypted outputs are identical without decrypting the ciphertext
View 5 Replies
View Related
Aug 1, 2013
I get the error of not declaring "text" "exit" but I how do I declared those variables, even if they cause problem to file... How can I output the decipher file in a new text...?
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <fstream>
#include <math.h>
[Code] ....
View 6 Replies
View Related
Mar 29, 2015
I have managed to print out the encrypted text from the console, however it doesnt decrypt correctly and isn't returning the correct key. I can't seem to find the error that is causing the decrypted text from printing correctly. When I try to decrypt the text it changes it completely as well.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "rotUtils.h"
bool solved( char decodearr[], char dictarr[][30], int size1, int size2){
char* compared;
bool result = false;
for(int j = 0; j < size2; j++){
[code]....
View 3 Replies
View Related
Jan 4, 2014
I finished my Enigma cipher simulator...how should I write the error handling code? Should I throw an exception in main, or in the Enigma ctor and Encrypt() fn when the user enters a non-alphanumeric character?
Rotor.hpp
Code:
#ifndef ROTOR_HPP
#define ROTOR_HPP
class Rotor {
public:
Rotor(char pos='A');
Rotor(const Rotor & rhs);
Rotor& operator=(const Rotor& rhs);
[Code] ....
Output
Code:
Enter rotor settings:
ABCDEFGHIJ
Enter cleartext:
HELLO WORLD
Ciphertext:
0O258 SGY5V
View 3 Replies
View Related
May 25, 2014
The assignment is to open an encrypted file, count the occurrence of each alphabetic character in the file. find the highest occurring letter and use that to find the shift, then apply the sift to the file in order to decipher and then print out the deciphered txt.
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main(){
string word;
ifstream txt;
int arr[26] = { 0 };
[Code] ....
View 5 Replies
View Related
Apr 15, 2013
I have assignment which requires me to print out and array code and a pseudo code. I dont no what a pseudo code is,.
View 2 Replies
View Related
Apr 13, 2014
I have a class 'A' which is almost perfect for my needs. Class 'B' uses class 'A' I've now designed Class 'C' and Class 'D' and noticed that there is a good chunk of code in class 'B', 'C' and 'D' for using Class 'A' is duplicated. I've separated out this code in specific, standalone functions in each of the classes. Now I'm wondering where this code should go. At the moment, the functions are duplicated in the three calling classes (B, C and D). Placing the functions into class 'A' would break the single responsibility principle. Inheritance to add functionality would likely break both SRP and LSP. The one that seems that it may work is composition.
However, Is designing a complete class just for a few functions over kill?
Would it be valid for classes 'B', 'C' and 'D' to access both the new class 'E' (which would depend on A) and the old class 'A' (which would have to be the same instance as the instance in the new class 'E'), or should the new class 'E' provide sufficient functionality so that Classes B, C and D don't need to access Class A directly? It would seem that its then an incomplete interface of the original object with additional functionality (ie, incompatible) Or should I do it a completely different way?
View 4 Replies
View Related
Apr 10, 2014
I'm having some problems with implementing an AI. It should be just a simple AI that follows player. Here is the code that I got so far:
(float)DirectionX = Circle->GetX() - AI->GetX();
(float)DirectionY = Circle->GetY() - AI->GetY();
(float)Hyp = sqrt(DirectionX * DirectionX + DirectionY * DirectionY);
DirectionX /= Hyp;
DirectionY /= Hyp;
x += DirectionX * 3;
y += DirectionY * 3;
This is what I got so far. It creates a vector in a direction I want to move, then just normalizes the vector. Simple as that. But I'm having 2 problems..
AI moves towards player only when Im at like the end of screen and the AI is on the other side, I must keep a certain distance for it to be able to move towards me. Basically, its not constantly moving towards the player. I also tried it with trig, using atan2 for angle and sin / cos for speed. Also didn't work, same result.
The other problem is when I want to add i.e 5 more AIs. For each new AI it creates, it makes a new update.. So, to kinda clear it up. If I'm in middle of the screen and an AI is spawned above me, it will move towards me. But when after that one, 2nd AI spawns beneath me, both 1st and 2nd AI move up. Basically, previous AIs take the update from last one that is created. For updating I'm using lists, objects and iters.
View 3 Replies
View Related
Jul 21, 2014
How do I play a simple mp3 through my mic. I plan on using this to just play annoying sounds through skype and games(on windows 7 btw).
View 6 Replies
View Related
Feb 12, 2014
I would like to know how can I make a simple program .exe so that I don't have to open it through code blocks every time.
View 2 Replies
View Related
Aug 8, 2013
I tried to write a simple program to calculate monthly yield, APR, and principle in various directions. Anyway, here's some code to get the APR from the principle and monthly yield. When I run it though, it spits 0 at me every time! What the problem is; the other functions work just fine and the code line for the APR calculation is just what it ought to be - I see neither a math nor tech problem here.
Here is the offending function:
Code:
void calculateAPR() {
int principle, monthlyYield, apr;
cout<<"
Please input the principle:";
cin>>principle;
cin.ignore();
[code]....
View 4 Replies
View Related
Jan 27, 2013
Code:
int i=5,j;
j=++i + ++i + ++i;
printf("%d",j); //22
i=5;
j=i++ + i++ + i++;
printf("%d",j); //19 Shall not it give 21 and 18 respectively?????
View 4 Replies
View Related
Oct 28, 2013
Just wondering about how to write extremely simple version of 'find' in C: It just lists the path names of the files in the specified directories and all subdirectories.For example,
Code:
$find_version .
./foo
./bar
./baz
./baz/other
[Code]....
View 6 Replies
View Related
Oct 5, 2013
I am writing a simple file parser for use in another project (for config file). The trickiest thing seems to be skipping unwanted characters (comments, spaces). It works partly, but after the second line of an inputed file processes only the first three characters.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TEXT_FILE "data.txt"
[code]....
NOTE: Currently I am just trying to process and remove unwanted data, the actual processing of extracted data should be much simpler.
View 6 Replies
View Related
Feb 28, 2013
So im just trying to read in an pgm file and store it in an array,
Code:
int** imageArray;
//allocate the image array
imageArray = (int**) malloc(row * sizeof(int*));
for(i = 0; i < row; i++)
imageArray[i] = (int*) malloc(col * sizeof(int));
[Code]....
It stores about 1/3 of the file into the array, and then starts printing 6815940 6819608 followed by a bunch of 0's.
View 10 Replies
View Related
Feb 27, 2014
3. Write a program that reads a sequence of positive integers and prints out their sum, except that if the same number occurs several times consecutively, ignore all but the first. Assume an input of 0 marks the end of the input. For example, if the input is 3 8 5 5 4 9 1 1 1 1 8 0 then you should print 38 (i.e., ignore one of the 5's and three of the 1's).
View 5 Replies
View Related
Jan 27, 2013
i want to improve my knowledge about the dyn allocation of char pointers... with this code i wanted to type a string and insert the string in a array created dynamically:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char c;
char *test=NULL;
unsigned int len;
}
[code]....
why there are these 3 initial character '' ')' ':' that i didn't have typed...
View 4 Replies
View Related
Dec 17, 2013
void viewWasteReport(){
EXEC SQL BEGIN DECLARE SECTION;
char wasteid[5],wastetype[31],month[11],wastequantity[13],wasteweight[11];
//double wastequantity[13];
//double wasteweight[11];
EXEC SQL END DECLARE SECTION;
fnConnectDB();
[Code] ....
I want to obtain the the product of wastequantity*wasteweight, but i get error.
View 6 Replies
View Related
Sep 20, 2014
I wish to create a simple animation, similar to the pong game but completely automatic (i.e. both sides play against eachother sort of like in a screensaver of sorts).
I am clueless on to even start tackling this, what tools to use and how to use them, to make them do what I want. I have had some experience with C++ scripting while modding Fallout 3, but I'm not sure how similar the scripting system available in the SDK for that game, is to the real thing.
Like I was saying I want to create a simple animation where two AI blocks try to prevent a ball from reaching the wall behind them.
View 3 Replies
View Related
Mar 20, 2014
I want to create a simple map editor in winforms. I would like for it to use a tile sheet from the user which they then can click on tiles from it and place it on the specified grid. Then export this as a binary file. Or perhaps it would be easier for the user to chose the grid size then have each grid space's number be able to be changed like 01,02,03 to represent an image. Then export this as a binary.
View 1 Replies
View Related