在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
虽然加密方式简单,但是Windows的注册表里面都使用了ROT13加密,可见其使用还是比较多的。 public string ROT13Encode(string InputText) { int i; char CurrentCharacter; int CurrentCharacterCode; string EncodedText = \"\"; //Iterate through the length of the input parameter for (i = 0; i < InputText.Length; i++) { //Convert the current character to a char CurrentCharacter = System.Convert.ToChar(InputText.Substring(i, 1)); //Get the character code of the current character CurrentCharacterCode = (int)CurrentCharacter; //Modify the character code of the character, - this //so that \"a\" becomes \"n\", \"z\" becomes \"m\", \"N\" becomes \"Y\" and so on if (CurrentCharacterCode >= 97 && CurrentCharacterCode <= 109) { CurrentCharacterCode = CurrentCharacterCode + 13; [Page] } else if (CurrentCharacterCode >= 110 && CurrentCharacterCode <= 122) { CurrentCharacterCode = CurrentCharacterCode - 13; } else if (CurrentCharacterCode >= 65 && CurrentCharacterCode <= 77) { CurrentCharacterCode = CurrentCharacterCode + 13; } else if (CurrentCharacterCode >= 78 && CurrentCharacterCode <= 90) { CurrentCharacterCode = CurrentCharacterCode - 13; } //Add the current character to the string to be returned EncodedText = EncodedText + (char)CurrentCharacterCode; } return EncodedText; } [Page] 加密和解密的方法都一样,把字符串传入方法返回得到的字符串就是要加密和解密的字符串了。 |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论