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 866 B

10 years ago
10 years ago
10 years ago
12345678910111213141516171819202122232425262728293031
  1. using System.Security.Cryptography;
  2. using System.Text;
  3. namespace Shadowsocks.Encrypt
  4. {
  5. public abstract class EncryptorBase
  6. : IEncryptor
  7. {
  8. protected EncryptorBase(string method, string password)
  9. {
  10. Method = method;
  11. Password = password;
  12. }
  13. protected string Method;
  14. protected string Password;
  15. protected byte[] GetPasswordHash()
  16. {
  17. byte[] inputBytes = Encoding.UTF8.GetBytes(Password);
  18. byte[] hash = MD5.Create().ComputeHash(inputBytes);
  19. return hash;
  20. }
  21. public abstract void Encrypt(byte[] buf, int length, byte[] outbuf, out int outlength);
  22. public abstract void Decrypt(byte[] buf, int length, byte[] outbuf, out int outlength);
  23. public abstract void Dispose();
  24. }
  25. }