Mavzu: des simmetrik kriptotizimi dasturiy modulini ishlab chiqish


Ishni bajarilish tartibi va qo’yilgan vazifa


Download 0.71 Mb.
bet2/2
Sana05.01.2022
Hajmi0.71 Mb.
#207242
1   2
Bog'liq
3lab

Ishni bajarilish tartibi va qo’yilgan vazifa


Asosiy matn shifrlash usullaridan birida shifrlansin va qadamma – qadam izohlansin. Shuningdek, Delpi, Java, C++ va C# dasturlash tizimlaridan birida dasturiy ta’minot yaratilsin.

TALABAGA TOPSHIRIQ!!!. Dasturiy ta’minotni ishlab chiqish va ushbu dastur talaba tomonidan ixtiyoriy dasturlash tili olinishi mumkin va hisobotda dasturiy ta’minot ishlashi to’liq tavsiflansin.

IKKITA BIR XIL ISH QABUL QILINMAYDI!!!!!
Men bu tajriba ishida C# dasturlash tilidan foydalanib, DES kriptotizimiga dastur tuzdim:

Bu dasturning visual ko’rinishi:


Shifrlash natijasi:

Dastur kodi:

DES shifri algoritmi (classi):

using System;

using System.Security.Cryptography;

using System.IO;

using System.Text;

namespace CIPHERS

{

class des



{

public static string Encrypt_DES(string source, string key)

{

try


{

using (TripleDESCryptoServiceProvider tripleDESCryptoService = new TripleDESCryptoServiceProvider())

{

using (MD5CryptoServiceProvider hashMD5Provider = new MD5CryptoServiceProvider())



{

byte[] byteHash = hashMD5Provider.ComputeHash(Encoding.UTF8.GetBytes(key));

tripleDESCryptoService.Key = byteHash;

tripleDESCryptoService.Mode = CipherMode.ECB;//CBC, CFB

byte[] data = Encoding.Unicode.GetBytes(source);

return Convert.ToBase64String(tripleDESCryptoService.CreateEncryptor().TransformFinalBlock(data, 0, data.Length));

}

}

}catch(Exception ex)



{

return "Xato";

}

}
public static string Decrypt_DES(string encrypt, string key)



{

try


{

using (TripleDESCryptoServiceProvider tripleDESCryptoService = new TripleDESCryptoServiceProvider())

{

using (MD5CryptoServiceProvider hashMD5Provider = new MD5CryptoServiceProvider())



{

byte[] byteHash = hashMD5Provider.ComputeHash(Encoding.UTF8.GetBytes(key));

tripleDESCryptoService.Key = byteHash;

tripleDESCryptoService.Mode = CipherMode.ECB;//CBC, CFB

byte[] byteBuff = Convert.FromBase64String(encrypt);

return Encoding.Unicode.GetString(tripleDESCryptoService.CreateDecryptor().TransformFinalBlock(byteBuff, 0, byteBuff.Length));

}

}

}catch(Exception ex)



{

return "xato";



}

}

}



}
Download 0.71 Mb.

Do'stlaringiz bilan baham:
1   2




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling