Click here to Skip to main content
15,881,559 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
Questionsingly linked list Pin
Member 1306030217-Jul-17 23:27
Member 1306030217-Jul-17 23:27 
AnswerRe: singly linked list Pin
Richard MacCutchan18-Jul-17 2:10
mveRichard MacCutchan18-Jul-17 2:10 
GeneralRe: singly linked list Pin
Member 1306030218-Jul-17 15:14
Member 1306030218-Jul-17 15:14 
GeneralRe: singly linked list Pin
Richard MacCutchan18-Jul-17 20:43
mveRichard MacCutchan18-Jul-17 20:43 
GeneralRe: singly linked list Pin
Member 1306030218-Jul-17 21:13
Member 1306030218-Jul-17 21:13 
GeneralRe: singly linked list Pin
Richard MacCutchan18-Jul-17 21:41
mveRichard MacCutchan18-Jul-17 21:41 
GeneralRe: singly linked list Pin
Member 1306030218-Jul-17 21:45
Member 1306030218-Jul-17 21:45 
QuestionStuck with one program. Pin
B.Sudhir25-Jun-17 16:58
B.Sudhir25-Jun-17 16:58 
I was praciticing an exercise in the book called C How to program by deitel. In which a question is there about cryptography.
Following is the question (Also notice to the phrase mentioned in BOLD letters).
Quote:
(Enforcing Privacy with Cryptography) The explosive growth of Internet communications and data storage on Internet-connected computers has greatly increased privacy concerns. The field of cryptography is concerned with coding data to make it difficult (and hopefully—with the most advanced schemes—impossible) for unauthorized users to read. In this exercise you’ll investigate a simple scheme for encrypting and decrypting data. A company that wants to send data over the Internet has asked you to write a program that will encrypt it so that it may be transmitted more securely. All the data is transmitted as four-digit integers. Your application should read a four-digit integer entered by the user and encrypt it as follows: Replace each digit with the result of adding 7 to the digit and getting the remainder after dividing the new value by 10. Then swap the first digit with the third, and swap the second digit with the fourth. Then print the encrypted integer. Write a separate application that inputs an encrypted four-digit integer and decrypts it (by reversing the encryption scheme) to form the original number. [Optional reading project: Research “public key cryptography” in general and the PGP (Pretty Good Privacy) specific public key scheme. You may also want to investigate the RSA scheme, which is widely used in industrial-strength applications.]


Following is the code block I've written for Encryption Scheme.

#include<stdio.h>

void main(){
    int iFirst;
    int iSecond;
    int iThird;
    int iFourth;
    int iTemp;

    printf("\nEnter four digits (with a space in between): ");
    scanf("%d %d %d %d", &iFirst, &iSecond, &iThird, &iFourth);

    iFirst = iFirst + 7;
    iSecond = iSecond + 7;
    iThird = iThird + 7;
    iFourth = iFourth + 7;

    iFirst = iFirst % 10;
    iSecond = iSecond % 10;
    iThird = iThird % 10;
    iFourth = iFourth % 10;

    //Swapping First <--> Third & Second <--> Fourth

    iTemp = iFirst;
    iFirst = iThird;
    iThird = iTemp;

    iTemp = iSecond;
    iSecond = iFourth;
    iFourth = iTemp;

    printf("\nEncrypted Data - %d%d%d%d", iFirst, iSecond, iThird, iFourth);
}


Output -
Quote:
Enter four digits (with a space in between): 1 2 3 4
1 2 3 4

Encrypted Data - 0189


and Decryption Scheme -

#include<stdio.h>

void main(){
    int iFirst;
    int iSecond;
    int iThird;
    int iFourth;
    int iTemp;

    printf("\nEnter encrypted four digits (with a space in between): ");
    scanf("%d %d %d %d", &iFirst, &iSecond, &iThird, &iFourth);

    iTemp = iFirst;
    iFirst = iThird;
    iThird = iTemp;

    iTemp = iSecond;
    iSecond = iFourth;
    iFourth = iTemp;

    iFirst = iFirst % 10;
    iSecond = iSecond % 10;
    iThird = iThird % 10;
    iFourth = iFourth % 10;

    iFirst = iFirst + 7;
    iSecond = iSecond + 7;
    iThird = iThird + 7;
    iFourth = iFourth + 7;



    //Swapping First <--> Third & Second <--> Fourth



    printf("\nDecrypted Data - %d%d%d%d", iFirst, iSecond, iThird, iFourth);
}


Output-
Quote:
Enter encrypted four digits (with a space in between)Blush | :O 1 8 9
0 1 8 9

Decrypted Data - 151678



Above programs should be working like this - if Encryption programs output for input 1234 is 0189 then Decryption program's output for input0189 should be 1234 but its not happening not sure why.

Can anyone help on this?
AnswerRe: Stuck with one program. Pin
Jochen Arndt25-Jun-17 21:40
professionalJochen Arndt25-Jun-17 21:40 
GeneralRe: Stuck with one program. Pin
B.Sudhir25-Jun-17 22:14
B.Sudhir25-Jun-17 22:14 
GeneralRe: Stuck with one program. Pin
Member 1496952719-Oct-20 7:29
Member 1496952719-Oct-20 7:29 
AnswerRe: Stuck with one program. Pin
Artur Linov IT25-Jul-17 6:43
Artur Linov IT25-Jul-17 6:43 
AnswerRe: Stuck with one program. Pin
Member 1496952719-Oct-20 7:04
Member 1496952719-Oct-20 7:04 
Questionprinting the customized data through printer in vc++ 6.0 dialog based. Pin
Member 1322408614-Jun-17 19:42
Member 1322408614-Jun-17 19:42 
AnswerRe: printing the customized data through printer in vc++ 6.0 dialog based. Pin
Richard MacCutchan14-Jun-17 22:50
mveRichard MacCutchan14-Jun-17 22:50 
GeneralRe: printing the customized data through printer in vc++ 6.0 dialog based. Pin
rahul199514-Jun-17 23:20
rahul199514-Jun-17 23:20 
GeneralRe: printing the customized data through printer in vc++ 6.0 dialog based. Pin
Richard MacCutchan15-Jun-17 1:04
mveRichard MacCutchan15-Jun-17 1:04 
GeneralRe: printing the customized data through printer in vc++ 6.0 dialog based. Pin
rahul199515-Jun-17 2:27
rahul199515-Jun-17 2:27 
GeneralRe: printing the customized data through printer in vc++ 6.0 dialog based. Pin
Richard MacCutchan15-Jun-17 2:57
mveRichard MacCutchan15-Jun-17 2:57 
GeneralRe: printing the customized data through printer in vc++ 6.0 dialog based. Pin
Richard MacCutchan15-Jun-17 3:06
mveRichard MacCutchan15-Jun-17 3:06 
GeneralRe: printing the customized data through printer in vc++ 6.0 dialog based. Pin
Richard MacCutchan15-Jun-17 6:15
mveRichard MacCutchan15-Jun-17 6:15 
GeneralRe: printing the customized data through printer in vc++ 6.0 dialog based. Pin
rahul199515-Jun-17 20:15
rahul199515-Jun-17 20:15 
GeneralRe: printing the customized data through printer in vc++ 6.0 dialog based. Pin
Richard MacCutchan15-Jun-17 21:26
mveRichard MacCutchan15-Jun-17 21:26 
GeneralRe: printing the customized data through printer in vc++ 6.0 dialog based. Pin
rahul199515-Jun-17 21:46
rahul199515-Jun-17 21:46 
GeneralRe: printing the customized data through printer in vc++ 6.0 dialog based. Pin
Richard MacCutchan15-Jun-17 21:53
mveRichard MacCutchan15-Jun-17 21:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.