تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[سؤال] جل إحترامي للجميع تشفير خوارزمية RSA
#4
RSA Encryption In VB.NET

كود :
Imports System.Security.Cryptography 'Import the cryptography namespaces
Imports System.Text

Public Class Form1

    'Declare global variables
    Dim textbytes, encryptedtextbytes As Byte()
    Dim rsa As New RSACryptoServiceProvider
    Dim encoder As New UTF8Encoding
    Dim encrypted, TextToDecrypt, TextToEncrypt, decrypted As String

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextToEncrypt = TextBox1.Text
        encrypt()
        TextBox2.Text = encrypted
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextToDecrypt = TextBox2.Text
        decrypt()
        TextBox3.Text = decrypted
    End Sub

    Sub encrypt()
        textbytes = encoder.GetBytes(TextToEncrypt)             'Use UTF8 to convert the text string into a byte array
        encryptedtextbytes = rsa.Encrypt(textbytes, True)       'encrypt the text
        encrypted = Convert.ToBase64String(encryptedtextbytes)  'Convert the encrypted byte array into a Base64 string for display purposes
    End Sub

    Sub decrypt()
        encryptedtextbytes = Convert.FromBase64String(TextToDecrypt)
        textbytes = rsa.Decrypt(encryptedtextbytes, True)   'get the decrypted clear text byte array
        decrypted = encoder.GetString(textbytes)            'convert the byte array to text using the same encoding format that was used for encryption
    End Sub

End Class
الرد }}}
تم الشكر بواسطة: Amir_Alzubidy


الردود في هذا الموضوع
RE: جل إحترامي للجميع . - بواسطة Genius Live - 15-02-14, 08:54 AM
RE: جل إحترامي للجميع . - بواسطة ليلى - 15-02-14, 09:19 AM
RE: جل إحترامي للجميع . - بواسطة vbnet - 15-02-14, 09:22 AM


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


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