تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[سؤال] بخصوص تشفير ملف txt
#13
المثال الذي وضعته لك يشفر كل أنواع الملفات مثل الصور و التكست و قواعد البيانات و حتى ملفات التنفيذية أي يشفر كل أنواع الملفات بلا استثناء .

إذا كنت تقصد تشفير ما بداخل الملف فهذا مثال على ذلك مأخوذ من هذه المشاركة ( منقول )  :

استفسار عن حقول تم تشفيرها

كود :
Public Function Encrypt(ByVal text As String, ByVal key As String) As String
       Try
           Dim crp As New TripleDESCryptoServiceProvider
           Dim uEncode As New UnicodeEncoding
           Dim bytPlainText() As Byte = uEncode.GetBytes(text)
           Dim stmCipherText As New MemoryStream
           Dim slt() As Byte = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
           Dim pdb As New Rfc2898DeriveBytes(key, slt)
           Dim bytDerivedKey() As Byte = pdb.GetBytes(24)
           crp.Key = bytDerivedKey
           crp.IV = pdb.GetBytes(8)
           Dim csEncrypted As New CryptoStream(stmCipherText, crp.CreateEncryptor(), CryptoStreamMode.Write)
           csEncrypted.Write(bytPlainText, 0, bytPlainText.Length)
           csEncrypted.FlushFinalBlock()
           Return Convert.ToBase64String(stmCipherText.ToArray())
       Catch ex As Exception
           MsgBox(ex.Message, MsgBoxStyle.Critical, "Error")
           Return Nothing
       End Try
   End Function
   Function Decrypt(ByVal text As String, ByVal key As String) As String
       Dim crp As TripleDESCryptoServiceProvider
       Try
           crp = New TripleDESCryptoServiceProvider
           Dim uEncode As New UnicodeEncoding
           Dim bytCipherText() As Byte = Convert.FromBase64String(text)
           Dim stmPlainText As New MemoryStream
           Dim stmCipherText As New MemoryStream(bytCipherText)
           Dim slt() As Byte = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
           Dim pdb As New Rfc2898DeriveBytes(key, slt)
           Dim bytDerivedKey() As Byte = pdb.GetBytes(24)
           crp.Key = bytDerivedKey
           crp.IV = pdb.GetBytes(8)

           Dim csDecrypted As New CryptoStream(stmCipherText, crp.CreateDecryptor(), CryptoStreamMode.Read)
           Dim sw As New StreamWriter(stmPlainText)
           Dim sr As New StreamReader(csDecrypted)
           sw.Write(sr.ReadToEnd)
           sw.Flush()
           csDecrypted.Clear()
           crp.Clear()
           Return uEncode.GetString(stmPlainText.ToArray())
       Catch ex As Exception
           MsgBox(ex.Message, MsgBoxStyle.Critical, "Error")
           Return Nothing
       End Try
   End Function
الرد }}}
تم الشكر بواسطة: elgokr , elgokr


الردود في هذا الموضوع
بخصوص تشفير ملف txt - بواسطة Mohamed20 - 30-09-16, 04:09 AM
RE: بخصوص تشفير ملف txt - بواسطة ممدوح - 01-10-16, 02:26 AM
RE: بخصوص تشفير ملف txt - بواسطة Mohamed20 - 01-10-16, 03:18 AM
RE: بخصوص تشفير ملف txt - بواسطة asemshahen5 - 13-10-18, 01:46 AM
RE: بخصوص تشفير ملف txt - بواسطة asemshahen5 - 13-10-18, 05:43 PM
RE: بخصوص تشفير ملف txt - بواسطة asemshahen5 - 03-11-18, 11:04 AM
RE: بخصوص تشفير ملف txt - بواسطة elgokr - 03-11-18, 01:19 PM
RE: بخصوص تشفير ملف txt - بواسطة elgokr - 06-11-18, 09:39 PM
RE: بخصوص تشفير ملف txt - بواسطة asemshahen5 - 07-11-18, 02:58 AM


التنقل السريع :


يقوم بقرائة الموضوع: