C/C++ 字串加密 可列印文本加密,字串列印文本

來源:互聯網
上載者:User

C/C++ 字串加密 可列印文本加密,字串列印文本

今天做了一個文本密碼編譯演算法, 由於是這個演算法是基於演算法保密的,沒有秘鑰,所有只能應付安全要求不高的需求,

如下

原文1
201411210H0g//60609.820
密文1
{*<P^o!1ARcw%8MXoz4;=fm i


原文2
201411210ab1234/32d fds
密文2
s"4HVgy)9J[o}0EPgs#35^Fxa

每次加密一行資料!!
希望大家喜歡

//strOut必須為可列印字元0x20 -- 0x7F//strOut必須以'\0'結尾,//加密效果較好 By Sols// 加密結果為可列印字元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可以為其他合適的數字while ( ResChar > 127){ResChar -= 96;}strOut[i] = (char)ResChar;}strOut[i++] =(char)( randOffset + 32 );strOut[i] = '\0';}//strOut必須為可列印字元 0x20 -- 0x7F//strOut必須以'\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;for ( ;strCode[i] != '\0';i++){ResChar = strCode[i] - Key - i*17;while ( ResChar < 32){ResChar += 96;}strCode[i] = (char)ResChar;}strCode[i-1] = '\0';}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.