PDA

View Full Version : حرفه ای: کمک جهت دیکد تابع



R2du-soft
یک شنبه 15 مرداد 1396, 04:12 صبح
دوستان 4 تا تابع دارم 2 تاش برای کدینگ string هست و 2 تاش برای دیکد
چون سا شارپم خیلی خوب نیست نمیتونم این کار رو انجامش بدم
میخوام وقتی متنی در textbox به صورت کد شد بیاد به صورت ساده نمایشش بده
و همچنین میخوام وقتی متنی داخل textbox به صورت ساده نوشته شده بود بیاد به صورت کدشده نشون بده


namespace Coding_SS
{
private __gc class enc_dec
{
// Methods
public: enc_dec()
{
base->.ctor();
return;
}


public: String __gc* Decrypt(String __gc* Data, String __gc* Password, Int32 __gc* Bits)
{
Byte __gc* buffer __gc [];
PasswordDeriveBytes __gc* bytes;
Boolean __gc* flag;
String __gc* str;
Boolean __gc* flag2;
Byte __gc* buffer2 __gc [];
Boolean __gc* flag3;
Boolean __gc* flag4;
Byte __gc* buffer3 __gc [];
Boolean __gc* flag5;
Boolean __gc* flag6;
Byte __gc* buffer4 __gc [];
String __gc* str2;
buffer = Convert::FromBase64String(Data);
bytes = __gc new PasswordDeriveBytes(Password, __gc new Byte __gc*[15] {
0, 1, 2, 0x1c, 0x1d, 30, 3, 4, 5, 15, 0x20, 0x21, 0xad, 0xaf, 0xa4});
flag = (Bits == 0x80);
if (flag == 0)
{
goto Label_005E;
}
buffer2 = this->Decrypt(buffer, bytes->GetBytes(0x10), bytes->GetBytes(0x10));
str = Encoding::Unicode->GetString(buffer2);
goto Label_00E8;
Label_005E:
flag3 = (Bits == 0xc0);
if (flag3 == 0)
{
goto Label_009B;
}
buffer3 = this->Decrypt(buffer, bytes->GetBytes(0x18), bytes->GetBytes(0x10));
str = Encoding::Unicode->GetString(buffer3);
goto Label_00E7;
Label_009B:
flag5 = (Bits == 0x100);
if (flag5 == 0)
{
goto Label_00D8;
}
buffer4 = this->Decrypt(buffer, bytes->GetBytes(0x20), bytes->GetBytes(0x10));
str = Encoding::Unicode->GetString(buffer4);
goto Label_00E6;
Label_00D8:
str = String::Concat(*static_cast<__box Int32*>(Bits));
Label_00E6:
Label_00E7:
Label_00E8:
str2 = str;
Label_00ED:
return str2;
}


private: Byte __gc* Decrypt(Byte __gc* cipherData __gc [], Byte __gc* Key __gc [], Byte __gc* IV __gc []) __gc []
{
MemoryStream __gc* stream;
Rijndael __gc* rijndael;
CryptoStream __gc* stream2;
Byte __gc* buffer __gc [];
stream = __gc new MemoryStream();
rijndael = Rijndael::Create();
rijndael->Key = Key;
rijndael->IV = IV;
stream2 = __gc new CryptoStream(stream, rijndael->CreateDecryptor(), 1);
stream2->Write(cipherData, 0, *static_cast<__box Int32*>(cipherData->Length));
stream2->Close();
buffer = stream->ToArray();
Label_0047:
return buffer;
}


private: Byte __gc* Encrypt(Byte __gc* clearData __gc [], Byte __gc* Key __gc [], Byte __gc* IV __gc []) __gc []
{
MemoryStream __gc* stream;
Rijndael __gc* rijndael;
CryptoStream __gc* stream2;
Byte __gc* buffer __gc [];
stream = __gc new MemoryStream();
rijndael = Rijndael::Create();
rijndael->Key = Key;
rijndael->IV = IV;
stream2 = __gc new CryptoStream(stream, rijndael->CreateEncryptor(), 1);
stream2->Write(clearData, 0, *static_cast<__box Int32*>(clearData->Length));
stream2->Close();
buffer = stream->ToArray();
Label_0047:
return buffer;
}


public: String __gc* Encrypt(String __gc* Data, String __gc* Password, Int32 __gc* Bits)
{
Byte __gc* buffer __gc [];
PasswordDeriveBytes __gc* bytes;
Boolean __gc* flag;
String __gc* str;
Boolean __gc* flag2;
Byte __gc* buffer2 __gc [];
Boolean __gc* flag3;
Boolean __gc* flag4;
Byte __gc* buffer3 __gc [];
Boolean __gc* flag5;
Boolean __gc* flag6;
Byte __gc* buffer4 __gc [];
String __gc* str2;
buffer = Encoding::Unicode->GetBytes(Data);
bytes = __gc new PasswordDeriveBytes(Password, __gc new Byte __gc*[15] {
0, 1, 2, 0x1c, 0x1d, 30, 3, 4, 5, 15, 0x20, 0x21, 0xad, 0xaf, 0xa4});
flag = (Bits == 0x80);
if (flag == 0)
{
goto Label_005E;
}
str = Convert::ToBase64String(this->Encrypt(buffer, bytes->GetBytes(0x10), bytes->GetBytes(0x10)));
goto Label_00DE;
Label_005E:
flag3 = (Bits == 0xc0);
if (flag3 == 0)
{
goto Label_0096;
}
str = Convert::ToBase64String(this->Encrypt(buffer, bytes->GetBytes(0x18), bytes->GetBytes(0x10)));
goto Label_00DD;
Label_0096:
flag5 = (Bits == 0x100);
if (flag5 == 0)
{
goto Label_00CE;
}
str = Convert::ToBase64String(this->Encrypt(buffer, bytes->GetBytes(0x20), bytes->GetBytes(0x10)));
goto Label_00DC;
Label_00CE:
str = String::Concat(*static_cast<__box Int32*>(Bits));
Label_00DC:
Label_00DD:
Label_00DE:
str2 = str;
Label_00E3:
return str2;
}


};
}