Files
shadowsocks-windows/shadowsocks-csharp/Encrypt/EncryptorBase.cs
T
2014-09-11 12:28:40 +08:00

30 lines
737 B
C#

using System.Security.Cryptography;
using System.Text;
namespace shadowsocks_csharp.Encrypt
{
public abstract class EncryptorBase
: IEncryptor
{
protected EncryptorBase(string method, string password)
{
Method = method;
Password = password;
}
protected string Method;
protected string Password;
protected byte[] GetPasswordHash()
{
byte[] inputBytes = Encoding.UTF8.GetBytes(Password);
byte[] hash = MD5.Create().ComputeHash(inputBytes);
return hash;
}
public abstract byte[] Encrypt(byte[] buf, int length);
public abstract byte[] Decrypt(byte[] buf, int length);
}
}