【发布时间】:2016-07-01 23:20:51
【问题描述】:
我到处寻找一个 C++ 代码,它接收来自用户的消息,并通过增加每个字符的 ASCII 值对其进行编码(显然不是很安全,但足够简单)。我已经设法组合了一个程序,该程序返回几个值更高的字符,但无法弄清楚如何使用包含空格的完整消息来做到这一点。我计划制作一个之后做相反的解码器。任何帮助将非常感激。提前致谢。
单值 C++ 程序 -
#include <iostream>
using namespace std;
int main(){
char ascii;
cout << "Enter a character: ";
cin >> ascii;
cout << "Its ascii value is: " << (int) ascii << endl;
return 0;
}
VBS 中的工作编码器示例 -
set x = WScript.CreateObject("WScript.Shell")
entxtde = inputbox("Enter text to be encoded")
entxtde = StrReverse(entxtde)
x.Run "%windir%\notepad"
wscript.sleep 1000
x.sendkeys encode(entxtde)
function encode(s)
For i = 1 To Len(s)
newtxt = Mid(s, i, 1)
newtxt = Chr(Asc(newtxt)+3)
coded = coded & newtxt
Next
encode = coded
End Function
【问题讨论】:
标签: c++ string encryption encoding ascii