سلام دوستان
من برای رمزنگاری اطلاعات از الگوریتم AES استفاده می کنم ولی به عنوان مثال اگر حرف a را رمزنگاری کنیم رشته رمزنگاری شده به صورت زیر خواهد بود :
Z+++c3ZSdlfmzLIX8SOR+A==
که خیلی طولانی و اگر بخواهیم یک جمله را رمزنگاری کنیم رشته تولید شده بسیار طولانی است
حالا برای اینکه طول رشته را کمتر کنیم باید ان را با الگوریتم هافمن فشرده کنیم ولی من نمی تونم با الگوریتم هافمن کار کنم
حالا من کلاس الگوریتم AES را میزارم اینجا لطفا بگید بعد از رمز نگاری با الگوریتم AES چطور رشته تولید شده را فشرده کنم

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.IO;
namespace Algorithm_AES
{
public class AES
{

public AES()
{
}

private byte[] Encrypt(byte[] clearData, byte[] Key, byte[] IV)
{

MemoryStream ms = new MemoryStream();

Rijndael alg = Rijndael.Create();
alg.Key = Key;

alg.IV = IV;
CryptoStream cs = new CryptoStream(ms, alg.CreateEncryptor(), CryptoStreamMode.Write);

cs.Write(clearData, 0, clearData.Length);
cs.Close();
byte[] encryptedData = ms.ToArray();
return encryptedData;
}


public string Encrypt(string Data, string Password, int Bits)
{

byte[] clearBytes = System.Text.Encoding.Unicode.GetBytes(Data);

PasswordDeriveBytes pdb = new PasswordDeriveBytes(Password,

new byte[] { 0x00, 0x01, 0x02, 0x1C, 0x1D, 0x1E, 0x03, 0x04, 0x05, 0x0F, 0x20, 0x21, 0xAD, 0xAF, 0xA4 });

if (Bits == 128)
{
byte[] encryptedData = Encrypt(clearBytes, pdb.GetBytes(16), pdb.GetBytes(16));
return Convert.ToBase64String(encryptedData);
}
else if (Bits == 192)
{
byte[] encryptedData = Encrypt(clearBytes, pdb.GetBytes(24), pdb.GetBytes(16));
return Convert.ToBase64String(encryptedData);
}
else if (Bits == 256)
{
byte[] encryptedData = Encrypt(clearBytes, pdb.GetBytes(32), pdb.GetBytes(16));
return Convert.ToBase64String(encryptedData);
}
else
{
return string.Concat(Bits);
}
}


private byte[] Decrypt(byte[] cipherData, byte[] Key, byte[] IV)
{

MemoryStream ms = new MemoryStream();
Rijndael alg = Rijndael.Create();
alg.Key = Key;
alg.IV = IV;
CryptoStream cs = new CryptoStream(ms, alg.CreateDecryptor(), CryptoStreamMode.Write);
cs.Write(cipherData, 0, cipherData.Length);
cs.Close();
byte[] decryptedData = ms.ToArray();
return decryptedData;
}


public string Decrypt(string Data, string Password, int Bits)
{

byte[] cipherBytes = Convert.FromBase64String(Data);

PasswordDeriveBytes pdb = new PasswordDeriveBytes(Password,

new byte[] { 0x00, 0x01, 0x02, 0x1C, 0x1D, 0x1E, 0x03, 0x04, 0x05, 0x0F, 0x20, 0x21, 0xAD, 0xAF, 0xA4 });

if (Bits == 128)
{
byte[] decryptedData = Decrypt(cipherBytes, pdb.GetBytes(16), pdb.GetBytes(16));
return System.Text.Encoding.Unicode.GetString(decryptedDa ta);
}
else if (Bits == 192)
{
byte[] decryptedData = Decrypt(cipherBytes, pdb.GetBytes(24), pdb.GetBytes(16));
return System.Text.Encoding.Unicode.GetString(decryptedDa ta);
}
else if (Bits == 256)
{
byte[] decryptedData = Decrypt(cipherBytes, pdb.GetBytes(32), pdb.GetBytes(16));
return System.Text.Encoding.Unicode.GetString(decryptedDa ta);
}
else
{
return string.Concat(Bits);
}

}

}
}