| |

VerySource

 Forgot password?
 Register
Search
View: 1010|Reply: 5

C# has a string encryption problem, please enlighten me

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-12-15 20:00:02
| Show all posts |Read mode
If there is a program to encrypt a string, the first character of the encrypted string is the last character of the original string, and each other character is the value of the previous character in the corresponding original character plus 3. For example, "WELCOME ", the character at the end is "E", "welcome" is added 3 in turn to become "zhofrp", and the result of encryption is "zhofrp".
Reply

Use magic Report

1

Threads

60

Posts

37.00

Credits

Newbie

Rank: 1

Credits
37.00

 China

Post time: 2020-12-15 21:45:01
| Show all posts
You can do this, make a 26-letter array, then save your string as an array, and then compare it with the 26-letter string. If you find the W character, then move to the +3 position, and then replace it, try test
Reply

Use magic Report

0

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 Singapore

Post time: 2020-12-19 08:00:01
| Show all posts
Isn't the first character the last character in the string? It should be Ehofrp after WELCOME encryption.
Reply

Use magic Report

1

Threads

7

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-12-19 21:30:01
| Show all posts
using System;

class Sample
{
public static void Main()
{
string input;
string output=null;
input = Console.ReadLine();
output += input[input.Length-1].ToString();
for (int i = 0; i <input.Length-1; i++)
{
output += ((char)(input[i] + 3)).ToString();
}
Console.WriteLine(output);
}
}
Reply

Use magic Report

1

Threads

7

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-12-19 22:30:01
| Show all posts
test
welcome
result
ezhofrp

right?
And what do you do if it is z? Is it z+3 or (z+3)%26=a?
Your question is not clear
Can only do this
Reply

Use magic Report

0

Threads

16

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-12-20 13:30:01
| Show all posts
Rotor encryption after character shift
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list