I am translating a decryption function that I have found on the internet. The function is written in Python, and I am translating it to C#. I have a fair amount of it done (hopefully correctly), but some of the syntax I'm having a hard time reading.
Here's the original function:
def decrypt_signature(s):
arr = list(s)
arr[0], arr[52] = arr[52%len(arr)], arr[0]
arr.reverse()
arr = arr[3:]
arr[0], arr[21] = arr[21%len(arr)], arr[0]
arr.reverse()
arr = arr[3:]
arr.reverse()
return "".join(arr)
And here's what I have translated so far:
private string DecryptSig(string s)
{
//arr = list(s)
char[] arr = s.ToArray();
//arr[0], arr[52] = arr[52%len(arr)], arr[0]
var temp = arr[0];
arr[0] = arr[52 % arr.Length];
arr[52 % arr.Length] = temp;
//arr.reverse()
arr.Reverse();
//arr = arr[3:]
//?????????????????
//arr[0], arr[21] = arr[21 % len(arr)], arr[0]
temp = arr[0];
arr[0] = arr[21 % arr.Length];
arr[21 % arr.Length] = temp;
//arr.reverse()
arr.Reverse();
//arr = arr[3:]
//??????????????????
//arr.reverse()
arr.Reverse();
//return "".join(arr)
return "" + new string(arr);
}
What does the author do when they write arr = arr[3:]? To me it appears like it's just taking the first three values of the array and writing them back to their original indices.