سلام...
چطور میشه تو سی شارپ یه فایلی ساخت که نشه با notepad یا هر چیز دیگه ای اونو باز کرد به عبارت دیگه توسط ویندوز ناشناخته بشه.
Printable View
سلام...
چطور میشه تو سی شارپ یه فایلی ساخت که نشه با notepad یا هر چیز دیگه ای اونو باز کرد به عبارت دیگه توسط ویندوز ناشناخته بشه.
notepad که می تونه هر فایلی رو باز کنه ! باید کاری کنی که نتونه اونو درست بخونه یا چشیز های نامفهوم نشون بده ! یکی از اون کار هام کدگذاری! می تونی اونو کد گذاری کنی که اطلاعات نامفهوم باشه!
موفق باشی
با سلام خدمت شما دوست گرامی
همونطور که دوست عزیزم هم گفتن باید روی فایل کد گذاری کنید,راحتترین کار اینه که به صورت باینری اونو ذخیره کنید اینجوری وقتی باز کنه فایلو کاراکترهای عجیب میبینه ,راه دیگش Hash کردن رشته ست که مثه :
private void Form1_Load(object sender, EventArgs e)
{
string str = "man younes safaieenia hastam";
MessageBox.Show(str.GetHashCode().ToString());
}
و ...
موفق باشین
بایت بایت
نقل قول:
notepad که می تونه هر فایلی رو باز کنه ! باید کاری کنی که نتونه اونو درست بخونه یا چشیز های نامفهوم نشون بده ! یکی از اون کار هام کدگذاری! می تونی اونو کد گذاری کنی که اطلاعات نامفهوم باشه
ببخشید کلاسی دارین که این کارو انجام بده یعنی کدگذاری کنه و از فایل کدگذاری شده بخونه؟
ممنون از توضیح شما اما (همون طور که خود شما هم گفتید)فکر کنم راه حل دوستمونmehdy.programmer بهتر باشه چون وقتی کد رو hash کنیم هرکسی که قضیه رو بفهمه میتونه دوباره با برنامه نویسی متنو بدست بیاره اما تو روش آقا mehdi اگه درست متوجه شده باشم هرکسی برای خودش یه کلاسی تعریف میکنه و با اون کلاس متنو کدگذاری می کنه.
خوب بله شما درست میگین به محض فهمیدن قضیه همه چی لو رفته ، برای همین بهتره از سیسنم های کد گذاری ابتکاری خودمون استفاده کنیم که کمتر کسی با اونا آشنایی داشته باشه !
هرچند برای این کار یه چند دوره ی کدگذاری و مطالعه چند کتاب و مقاله و بررسی سیستم های کدگذاری معروف لازمه!
ولی شما همچنان می تونین از HashCode , MD5 و ... استفاده کنین!
نه داداش بهترین راه AES است
چون MD5 و Sha1 یک طرفه هستند یعنی چیزی رو که رمز نگاری کردی قابل برگشت نیست!
از AES استفاده کن
واسه کلاسش هم یه کلاس بساز بنام AES.cs بعد اینارو کلا کپی کن:
using System;
using System.Security.Cryptography;
using System.IO;
namespace AES_Encryption
{
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;
}
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);
}
}
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);
}
}
}
}
سلام
این کلاس رو باید چطوری استفاده کرد