菜神提问
using System;
public interface IBindesh
{
string encode(string str);
string decode(string str);
}
namespace EncryptionDecryption
{
/// <summary>
/// 加密解密
/// </summary>
public class EncryptionDecryption : IBindesh
{
public string encode(string str)
{
string htext = " ";
for ( int i = 0; i < str.Length; i++)
{
htext = htext + (char) (str[i] + 10 - 1 * 2);
}
return htext;
}
public string decode(string str)
{
string dtext = " ";
for ( int i=0; i < str.Length; i++)
{
dtext = dtext + (char) (str[i] - 10 + 1*2);
}
return dtext;
}
}
public class test
{
public static void aa()
{
EncryptionDecryption inter = new EncryptionDecryption();
Console.WriteLine(((IBindesh)inter).encode( "aa "));
System.Console.ReadLine();
}
}
}
哪位高手能详细解释上面的这段代码?
[解决办法]
定义加密解密接口,并实现,然后调用
[解决办法]
输入一个字符串 对每一位字母进行+10-2操作 (加密) 解密做逆操作
PS:(ascii)+10-2 变成另一个字母了
[解决办法]
定义接口
写个类实现这个接口
创建类对像,并调用