ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • encrypt(암호화) 프로그래밍 c++
    카테고리 없음 2013. 11. 29. 22:21
    반응형


    단순 문자열을 암호화 하기 : 



    //

    //  main.cpp

    //  encrypt

    //

    //  Created by Gavin on 2013. 11. 29..

    //  Copyright (c) 2013 Gavin. All rights reserved.

    //


    #include <iostream>

    using std::cout;

    using std::endl;

    void encrypt(char[]);

    void decrypt(char * ePtr);


    int main(int argc, const char * argv[])

    {

        // create a string to encrypt

        char string[ ] = "this is a secret!";

        cout << "Original string is: " << string << endl;

        encrypt( string );

        // call to the function encrypt( )

        cout << "Encrypted string is: " << string << endl;

        decrypt( string );

        // call to the function decrypt( )

        cout << "Decrypted string is: " << string << endl;

        

           return 0;

    }


    //encrypt data

    void encrypt (char e[] )

    {

        for( int i=0; e[i] != '\0'; ++i ) ++e[i];

    } // encrypt


    //decrypt data

    void decrypt( char * ePtr ) {

        for( ; * ePtr != '\0'; ++* ePtr ) --(* ePtr);

    }

    반응형
Designed by Tistory.