String Plus decryption

Source: Internet
Author: User

Title Description

1, the input string is added and decrypted, and output.

2 Encryption methods are:

    • When the content is a number then add 1, such as 0 replace the 2,9 replacement 0;

    • Other characters do not change.

3, the decryption method is the inverse process of encryption.

Interface Description:

Implement interfaces, each of which implements 1 basic operations:

  • voidEncrypt (Char Aucpassword[], char aucresult[] ): In this function, implement thestringEncrypt and output

Description

1 , the string ends with a.

2 , the string is up to 100 characters long.

    • int Unencrypt (char result[], char password[]): implement string decryption and output in this function

Description

1 , the string ends with a.

2 , the string is up to 100 characters long.


Full code:

/****************************************************************************** Copyright (C), 2001-2011, Huawei       Tech. Co., Ltd. ****************************************************************************** File name:version                : Author:created:2012/03/12 last Modified:Description:Function List: HISTORY:1.DATE:2012/03/12 Author:Modification:Created file******************************* /#include <stdlib.h> #include <string.h> #include < STDIO.H&GT;//1, the input string is added and decrypted, and output. 2 The Encryption method is://When the content is an English letter is replaced with the letter of the latter letter, while the letter conversion case, such as the letter A is replaced by B; When the letter z is replaced by the a;//when the content is a number 1, such as 0 to replace the replacement 2,9 replacement 0;// Other characters do not change. 3, the decryption method is the inverse process of encryption.         int Encrypt (char password[], char result[]) {/* code implemented HERE */while (*password!= ' + ') {if (*password== ' 9 ') {        *result++= ' 0 ';      password++; } else if (*password>= ' 0 ' &&*password< ' 9 ') {*result++=*password+1;      password++;        } else if (*password== ' Z ') {*result++= ' a ';      password++;        } else if (*password== ' z ') {*result++= ' A ';      password++;        } else if (*password>= ' A ' &&*password< ' Z ') {*result++=*password+33;      password++;        } else if (*password>= ' a ' &&*password< ' Z ') {*result++=*password-31;      password++;            } else *result++=*password++;  } *result= ' + '; return 0;} int Unencrypt (char result[], char password[]) {/* code implemented HERE */while (*result!= '} ') {if (*result>= ' 1 ' &&am        p;*result<= ' 9 ') {*password++=*result-1;      result++;        } else if (*result== ' 0 ') {*password++= ' 9 ';      result++;        } else if (*result>= ' B ' &&*result<= ' Z ') {*password++=*result-33;      result++; } else if (*result== ' a ') {*password++= ' Z ';      result++;        } else if (*result>= ' B ' &&*result<= ' Z ') {*password++=*result+31;      result++;        } else if (*result== ' A ') {*password++= ' z ';      result++;    } else *password++=*result++;  } *password= ' + '; return 0;}


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

String Plus decryption

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.