C/C ++ string encryption: printable text encryption; string printing text

Source: Internet
Author: User
Tags printable characters

C/C ++ string encryption: printable text encryption; string printing text

Today, we developed a text encryption algorithm. Because it is based on the algorithm's confidentiality and has no key, it can only meet the security requirements,

As follows:

Article 1
201411210H0g // 60609.820
Ciphertext 1
{* <P ^ o! 1 ARcw % 8MXoz4; = fm I


Article 2
201411210ab1234/32d fds
Ciphertext 2
S "4 HVgy) 9J [o} 0 EPgs #35 ^ Fxa

Encrypt a row of data each time !!
Hope you like it

// StrOut must be printable characters 0x20 -- 0x7F // strOut must end with '\ 0, // encryption is better By Sols // The encryption result is printable characters 0x20 -- 0x7Fvoid EnCodeStr (char * strOut) {int randOffset = rand () % 96; int ResChar; int I = 0; for (; strOut [I]! = '\ 0'; I ++) {ResChar = randOffset + strOut [I] + I * 17; // 17 can be a suitable number while (ResChar> 127) {ResChar-= 96;} strOut [I] = (char) ResChar;} strOut [I ++] = (char) (randOffset + 32 ); strOut [I] = '\ 0';} // The strOut must be printable characters 0x20 -- 0x7F // The strOut must end with' \ 0, void DeCodeStr (char * strCode) {int KeyIndex = 0; if (strCode [0] = '\ 0') return; while (strCode [KeyIndex]! = '\ 0') {KeyIndex ++;} int Key = (int) (strCode [KeyIndex-1])-32; int ResChar; int I = 0; (; strCode [I]! = '\ 0'; I ++) {ResChar = strCode [I]-Key-I * 17; while (ResChar <32) {ResChar + = 96 ;} strCode [I] = (char) ResChar;} strCode [I-1] = '\ 0 ';}

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.