KekSec icon

crypter code

KekSec | PRO | 06/23/20 04:30:51 AM UTC | 0 ⭐ | 3489 👁️ | Never ⏰ | []
C# |

1.17 KB

|

None

|

0 👍

/

0 👎

    public static class Decryptor
    {
        public static byte[] Decrypt(byte[] key, byte[] data)
        {
            return EncryptOutput(key, data).ToArray();
        }
        private static byte[] EncryptInitalize(byte[] key)
        {
            byte[] s = Enumerable.Range(0, 256)
              .Select(i => (byte)i)
              .ToArray();
 
            for (int i = 0, j = 0; i < 256; i++)
            {
                j = (j + key[i % key.Length] + s[i]) & 255;
 
                Swap(s, i, j);
            }
 
            return s;
        }
        private static IEnumerable<byte> EncryptOutput(byte[] key, IEnumerable<byte> data)
        {
            byte[] s = EncryptInitalize(key);
 
            int i = 0;
            int j = 0;
 
            return data.Select((b) =>
            {
                i = (i + 1) & 255;
                j = (j + s[i]) & 255;
 
                Swap(s, i, j);
 
                return (byte)(b ^ s[(s[i] + s[j]) & 255]);
            });
        }
        private static void Swap(byte[] s, int i, int j)
        {
            byte c = s[i];
 
            s[i] = s[j];
            s[j] = c;
        }
 
    }

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎