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:
Description
1 , the string ends with a.
2 , the string is up to 100 characters long.
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>//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