• ¡Welcome to Square Theme!
  • This news are in header template.
  • Please ignore this message.
مهمان عزیز خوش‌آمدید. ورود عضــویت


امتیاز موضوع:
  • 18 رای - 2.11 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
Title: سورس کد الگوریتم رمزنگاری AES (سی شارپ)
حالت موضوعی
#1
In cryptography, the Advanced Encryption Standard (AES) is a symmetric-key encryption standard. This standard comprises three block ciphers, AES-128, AES-192 and AES-256, adopted from a larger collection originally published as Rijndael. Each of these ciphers has a 128-bit block size, with key sizes of 128, 192 and 256 bits.
What Is Encryption?
Encryption is the process of changing data into a form that can be read only by the intended receiver. To decipher the message, the receiver of the encrypted data must have the proper decryption key (password). In traditional encryption schemes, the sender and the receiver use the same key to encrypt and decrypt data. In this case the key is the password you supply.
Example Uses For Encryption
Many modern day systems process data which is considered sensitive. For example, doctors store patient information, stock brokers store client financial data and home computer users store personal information on their computers — their own personal information. All this information is vulnerable to exposure in the event of the theft of the computer itself.
Should you find yourself fortunate enough to be developing software in C# then you may find the following code snippets beneficial.
کد:
01public static string Encrypt(string PlainText, string Password, string Salt, string HashAlgorithm, int PasswordIterations, string InitialVector, int KeySize)
{
try
{
byte[] InitialVectorBytes = Encoding.ASCII.GetBytes(InitialVector);
byte[] SaltValueBytes = Encoding.ASCII.GetBytes(Salt);
byte[] PlainTextBytes = Encoding.UTF8.GetBytes(PlainText);
PasswordDeriveBytes DerivedPassword = new PasswordDeriveBytes(Password, SaltValueBytes, HashAlgorithm, PasswordIterations);
byte[] KeyBytes = DerivedPassword.GetBytes(KeySize / 8);
RijndaelManaged SymmetricKey = new RijndaelManaged();
SymmetricKey.Mode = CipherMode.CBC;
ICryptoTransform Encryptor = SymmetricKey.CreateEncryptor(KeyBytes, InitialVectorBytes);
MemoryStream MemStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(MemStream, Encryptor, CryptoStreamMode.Write);
cryptoStream.Write(PlainTextBytes, 0, PlainTextBytes.Length);
cryptoStream.FlushFinalBlock();
byte[] CipherTextBytes = MemStream.ToArray();
MemStream.Close();
cryptoStream.Close();
MemStream.Dispose();
cryptoStream.Dispose();
Encryptor.Dispose();
return Convert.ToBase64String(CipherTextBytes);
}
catch (Exception ex)
{
throw ex;
}
}

سمپل (اینکود)
کد:
Encrypt("mykey", "mypassword", "mysalt", "MD5",5, "qwertyuiqwertyui", 256);



کد:
public static string Decrypt(string CipherText, string Password, string Salt, string HashAlgorithm, int PasswordIterations, string InitialVector, int KeySize)
{
try
{
byte[] InitialVectorBytes = Encoding.ASCII.GetBytes(InitialVector);
byte[] SaltValueBytes = Encoding.ASCII.GetBytes(Salt);
byte[] CipherTextBytes = Convert.FromBase64String(CipherText);
PasswordDeriveBytes DerivedPassword = new PasswordDeriveBytes(Password, SaltValueBytes, HashAlgorithm, PasswordIterations);
byte[] KeyBytes = DerivedPassword.GetBytes(KeySize / 8);
RijndaelManaged SymmetricKey = new RijndaelManaged();
SymmetricKey.Mode = CipherMode.CBC;
ICryptoTransform Decryptor = SymmetricKey.CreateDecryptor(KeyBytes, InitialVectorBytes);
MemoryStream MemStream = new MemoryStream(CipherTextBytes);
CryptoStream cryptoStream = new CryptoStream(MemStream, Decryptor, CryptoStreamMode.Read);
byte[] PlainTextBytes = new byte[CipherTextBytes.Length];
int ByteCount = cryptoStream.Read(PlainTextBytes, 0, PlainTextBytes.Length);
MemStream.Close();
cryptoStream.Close();
MemStream.Dispose();
cryptoStream.Dispose();
Decryptor.Dispose();
return Encoding.UTF8.GetString(PlainTextBytes, 0, ByteCount);
}
catch (Exception ex)
{
throw ex;
}
}
سمپل دکود :
کد:
Decrypt("ND5lYPo4czOk5ZT7KNmU2Q==", "mypassword", "mysalt", "MD5",5, "qwertyuiqwertyui", 256);
گروه دور همی پارسی کدرز
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg
 
پاسخ
#2
سلام نگفتيد اين كده ها را در كلاس بنويسيم يا بدنه اصلي برنامه
 
پاسخ
  


موضوعات مشابه ...
موضوع نویسنده پاسخ بازدید آخرین ارسال
  سورس کد تبدیل عکس رنگی به سیاه سفید (سی شارپ) Amin_Mansouri 1 7,637 10-08-2022، 08:06 PM
آخرین ارسال: sonusood
  سورس کد تبدیل عکس به ایکون ( سی شارپ ) Amin_Mansouri 1 4,782 10-08-2022، 07:37 PM
آخرین ارسال: sonusood
  سورس کد تغییر دادن سایز عکس ( سی شارپ) Amin_Mansouri 1 7,213 10-08-2022، 07:08 PM
آخرین ارسال: sonusood
  سورس کد ساخت فایل pdf (سی شارپ) Amin_Mansouri 3 13,022 07-01-2017، 10:05 AM
آخرین ارسال: 7seo
  کد ssim در سی شارپ saraj00n 4 6,810 05-22-2017، 04:33 PM
آخرین ارسال: delsanik91
  سورس کد الگوریتم رمزنگاری تصویر زهرا ترکاشوند 3 10,055 05-17-2016، 01:41 PM
آخرین ارسال: mehdisadeghi
  سورس کد ifc saraj00n 1 4,095 05-13-2016، 01:46 PM
آخرین ارسال: saraj00n
  کد سی شارپ Save,SaveAs razi0tn 0 4,034 01-19-2016، 02:53 PM
آخرین ارسال: razi0tn
  سورس کد اضافه ,ویرایش,حذف,جستجو در دیتابیس(سی شارپ) Amin_Mansouri 6 25,345 12-09-2015، 08:17 AM
آخرین ارسال: Amin_Mansouri
  فروش سورس کد کتابساز اندروید دانشجو omid_student 1 5,046 08-12-2014، 11:00 AM
آخرین ارسال: Amin_Mansouri

پرش به انجمن:


Browsing: 3 مهمان