تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[VB.NET] كود حفظ النص مشفر في قاعدة البينات
#2
سلام


هذا الرابط فيه التشفير وفك التشفير
https://msdn.microsoft.com/en-us/library/ms172831.aspx
كود :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

   Dim s As String = "الطالب"

   Dim es As String = EncryptData(s)
   MsgBox(es)

   Dim ds As String = DecryptData(es)
   MsgBox(ds)

End Sub

#Region " Encrypting and Decrypting "
'https://msdn.microsoft.com/en-us/library/ms172831(v=vs.100).aspx

Private TripleDes As New Security.Cryptography.TripleDESCryptoServiceProvider

Public Function EncryptData(ByVal plaintext As String) As String

   ' Convert the plaintext string to a byte array.
   Dim plaintextBytes() As Byte = System.Text.Encoding.Unicode.GetBytes(plaintext)

   ' Create the stream.
   Dim ms As New System.IO.MemoryStream
   ' Create the encoder to write to the stream.
   Dim encStream As New Security.Cryptography.CryptoStream(ms, TripleDes.CreateEncryptor(), System.Security.Cryptography.CryptoStreamMode.Write)

   ' Use the crypto stream to write the byte array to the stream.
   encStream.Write(plaintextBytes, 0, plaintextBytes.Length)
   encStream.FlushFinalBlock()

   ' Convert the encrypted stream to a printable string.
   Return Convert.ToBase64String(ms.ToArray)
End Function

Public Function DecryptData(ByVal encryptedtext As String) As String

   ' Convert the encrypted text string to a byte array.
   Dim encryptedBytes() As Byte = Convert.FromBase64String(encryptedtext)

   ' Create the stream.
   Dim ms As New System.IO.MemoryStream
   ' Create the decoder to write to the stream.
   Dim decStream As New Security.Cryptography.CryptoStream(ms, TripleDes.CreateDecryptor, System.Security.Cryptography.CryptoStreamMode.Write)

   ' Use the crypto stream to write the byte array to the stream.
   decStream.Write(encryptedBytes, 0, encryptedBytes.Length)
   decStream.FlushFinalBlock()

   ' Convert the plaintext stream to a string.
   Return System.Text.Encoding.Unicode.GetString(ms.ToArray)
End Function
#End Region


موفقين
متغيب
الرد }}}
تم الشكر بواسطة: moha11


الردود في هذا الموضوع
RE: كود حفظ النص مشفر في قاعدة البينات - بواسطة الطالب - 05-09-15, 01:02 PM

المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  كيف نستخرج نص الالتاريخ الاول من النص التالي: justforit 0 131 31-10-25, 05:33 PM
آخر رد: justforit
  [سؤال] طريقة توسيط النص داخل اداة comboBox سمير1404 7 3,860 24-08-25, 01:01 PM
آخر رد: أبو خالد الشكري
  [Acces2007] مشكلة ملف قاعدة بيانات access للقراءة فقط mmaalmesry 11 1,476 29-04-25, 08:55 PM
آخر رد: mmaalmesry
Photo لايمكن تعرف على تنسيق قاعدة البيانات الدريساوي 2 697 26-04-25, 12:24 AM
آخر رد: الدريساوي
  مساعدة في طريقة تحميل الفيديوهات المخزنة في قاعدة البيانات foad8920 0 663 24-04-25, 12:58 PM
آخر رد: foad8920
  مشكلة عدم قراءة قاعدة بيانات MS access 0 424 29-03-25, 01:58 PM
آخر رد: ibraa939
  مشكلة عدم قراءة قاعدة بيانات MS access 0 354 29-03-25, 01:57 PM
آخر رد: ibraa939
  مشكلة عدم قراءة قاعدة بيانات MS access 0 291 29-03-25, 01:57 PM
آخر رد: ibraa939
  [كود] كود تغيير حجم النص في التكست بوكس hassan 8 8,796 30-01-25, 02:33 AM
آخر رد: خالد كامل1
  [سؤال] كود قاعدة بيانات visual basic 2010 express KHALED987 1 510 25-01-25, 12:39 PM
آخر رد: Kamil

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


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