C + + string encryption printable text encryption

Source: Internet
Author: User
Tags printable characters

Today made a text encryption algorithm, because this algorithm is based on algorithm secrecy, no secret key, all can only meet the requirements of low security requirements,


Strout must be 0x20 for printable characters--0x7f//strout must end with '/',//encryption works better by sols//encryption result as printable character 0x20--0x7fvoid encodestr (char *strout) {int Randoffset = rand ()%96;int reschar; int i=0;for (; strout[i]! = ' i++ '; reschar) {Randoffset = Strout[i + I*17;//17] + can be used for other Appropriate number while (Reschar > 127) {Reschar-= 96;} Strout[i] = (char) Reschar;} strout[i++] = (char) (randoffset + +); Strout[i] = ' + ';} Strout must be 0x20 for printable characters--0x7f//strout must end With ' *strcode ', void Decodestr (char KeyIndex) {int 0;if = strcode[0 (
   
    return;while (Strcode[keyindex]! = ' + ') {keyindex++;}  int Key = (int) (strcode[keyindex-1])-32;int reschar; int i=0;for (; strcode[i]! = ' + '; i++) {Reschar = Strcode[i]-Key- I*17;while (Reschar < +) {Reschar + = 96;} Strcode[i] = (char) Reschar;} Strcode[i-1] = ' + ';}
   

C + + string encryption printable text encryption

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.