Home > Net >  To solve the
To solve the

Time:09-24

3. The encryption program
Write a console application to input string encryption and decryption, for alphabetic string encryption rules are as follows:
'a' to 'd' b ', 'e' 'w' - 'z'... 'x' to 'a' 'y', 'b' 'z' -> 'c'
'A' to 'B' 'B', 'E' 'W' - 'Z'... 'X' to 'A' 'Y', 'B' 'Z' -> 'C'
For other characters, not encrypted,
Program running effect as shown in figure 2,

Figure 2 encryption program


Tip:
(1) traverses the original each character string, such as the character is not a to z or a to z, without encryption, keeping its original characters, so a to z or a to z, then according to the following method to convert ciphertext corresponding characters,
(1) judging character is a to z, a to z, judging its ASCII value available, such as character ch:
A to z: (ch & gt;=65 & amp; & Ch & lt;=90) or (ch & gt;='a' & amp; & Ch & lt;='z')
A to Z: (ch & gt;=97 & amp; & Ch & lt;=122) or (ch & gt;='A' & amp; & Ch & lt;='Z')
(2) for character a ~ w, a ~ w, because 'a' -> 'd', 'b' and 'e'... , cipher text characters of ASCII value is larger than the original characters of the ASCII value of 3, so:
Encrypted characters=(char) (the original character + 3)
For the characters in ch, encrypted characters: (char) (ch + 3)
But for the characters of the x, y, z, x, y, z, when convert ciphertext need special processing, can pass judgment statements,

CodePudding user response:

The teacher the assignment,

CodePudding user response:

A bit simple,

CodePudding user response:

For loop traverse character, then the cycle to judge, judge the conditions in the title made it very clear

CodePudding user response:

It's too hard to not

CodePudding user response:

String STR="dfsadb456a132c5adf3";
The StringBuilder=sb=new StringBuilder ();
for(int i=0; I{
If (STR [I] equals (" a "))
{
Sb. Append (" encryption ");
}
The else
{
Sb. Append (STR [I]);
}
}
  •  Tags:  
  • C#
  • Related