You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

EncryptorBase.cs 1.2 kB

11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
11 years ago
11 years ago
123456789101112131415161718192021222324252627282930313233343536
  1. namespace Shadowsocks.Encryption
  2. {
  3. public abstract class EncryptorBase : IEncryptor
  4. {
  5. public const int MAX_INPUT_SIZE = 32768;
  6. public const int MAX_DOMAIN_LEN = 255;
  7. public const int ADDR_PORT_LEN = 2;
  8. public const int ADDR_ATYP_LEN = 1;
  9. public const int ATYP_IPv4 = 0x01;
  10. public const int ATYP_DOMAIN = 0x03;
  11. public const int ATYP_IPv6 = 0x04;
  12. public const int MD5_LEN = 16;
  13. protected EncryptorBase(string method, string password)
  14. {
  15. Method = method;
  16. Password = password;
  17. }
  18. protected string Method;
  19. protected string Password;
  20. public abstract void Encrypt(byte[] buf, int length, byte[] outbuf, out int outlength);
  21. public abstract void Decrypt(byte[] buf, int length, byte[] outbuf, out int outlength);
  22. public abstract void EncryptUDP(byte[] buf, int length, byte[] outbuf, out int outlength);
  23. public abstract void DecryptUDP(byte[] buf, int length, byte[] outbuf, out int outlength);
  24. public int AddressBufferLength { get; set; } = -1;
  25. }
  26. }