加密解密:C#中使用ROT13加密解密



ROT13是种简单加密方式主要是把26个英文字母前13个和后13个对调起到英文文字加密保护作用 今天我们来看下在C#中使用ROT13加密解密实现我们就用个例子来为大家解答下把www.
虽然加密方式简单但是Windows注册表里面都使用了ROT13加密可见其使用还是比较多
publicROT13Encode(InputText)
{
i;
charCurrentCharacter;
CurrentCharacterCode;
EncodedText=\"\";
//Iteratethroughthelengthoftheinputparameter
for(i=0;i<InputText.Length;i)
{
//Convertthecurrentcharactertoachar
CurrentCharacter=.Convert.ToChar(InputText.Sub(i,1));
//Getthecharactercodeofthecurrentcharacter
CurrentCharacterCode=()CurrentCharacter;
//Modythecharactercodeofthecharacter,-this
//sothat\"a\"becomes\"n\",\"z\"becomes\"m\",\"N\"becomes\"Y\"andsoon
(CurrentCharacterCode>=97&&CurrentCharacterCode<=109)
{
CurrentCharacterCode=CurrentCharacterCode+13; [Page]
}
(CurrentCharacterCode>=110&&CurrentCharacterCode<=122)
{
CurrentCharacterCode=CurrentCharacterCode-13;
}
(CurrentCharacterCode>=65&&CurrentCharacterCode<=77)
{
CurrentCharacterCode=CurrentCharacterCode+13;
}
(CurrentCharacterCode>=78&&CurrentCharacterCode<=90)
{
CurrentCharacterCode=CurrentCharacterCode-13;
}
//Addthecurrentcharactertothetobeed


EncodedText=EncodedText+(char)CurrentCharacterCode;
}
EncodedText;
} [Page]
加密和解密思路方法都串传入思路方法返回得到串就是要加密和解密串了
Tags:  解密加密.exe 加密解密软件 加密与解密 加密解密

延伸阅读

最新评论

发表评论