Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. about encrypt and dcrypt of a text

about encrypt and dcrypt of a text

Scheduled Pinned Locked Moved Visual Basic
databasesecurityhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lavankumar
    wrote on last edited by
    #1

    hi i want to store a password in the database. for that i m using encrypt and decrypt for this task i written the following code i can perform encrypt but while decrypting i could not get back the actual text please help me ... this is the code i written .... Imports System Imports System.Text Imports System.Security Imports System.Security.Cryptography Imports System.Web.Security Public Class Form1 Dim xmlpublickey As String Dim xmlprivatekey As String Dim plaintextarray() As Byte Dim hpertextarrray() As Byte Dim restoredPlainText() As Byte Dim RSA As New RSACryptoServiceProvider Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load xmlprivatekey = RSA.ToXmlString(True) xmlpublickey = RSA.ToXmlString(False) End Sub Public Sub Encrypt() RSA.FromXmlString(xmlpublickey) Dim msg As String = "" msg = txtoriginal.Text Dim ue As New UnicodeEncoding plaintextarray = ue.GetBytes(msg) hpertextarrray = RSA.Encrypt(plaintextarray, False) txtcypher.Clear() For i As Integer = 0 To hpertextarrray.Length - 1 txtcypher.Text = txtcypher.Text + hpertextarrray(i).ToString() Next End Sub Public Sub Decrypt() RSA.FromXmlString(xmlprivatekey) restoredPlainText = RSA.Decrypt(hpertextarrray, False) txtRestrored.Clear() Dim str As Byte For i As Integer = 0 To restoredPlainText.Length - 1 str = restoredPlainText(i).ToString() txtRestrored.Text += GetChar(str, 1) Next End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Encrypt() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Decrypt() End Sub End Class thanks in advance lavan kumar

    D 1 Reply Last reply
    0
    • L lavankumar

      hi i want to store a password in the database. for that i m using encrypt and decrypt for this task i written the following code i can perform encrypt but while decrypting i could not get back the actual text please help me ... this is the code i written .... Imports System Imports System.Text Imports System.Security Imports System.Security.Cryptography Imports System.Web.Security Public Class Form1 Dim xmlpublickey As String Dim xmlprivatekey As String Dim plaintextarray() As Byte Dim hpertextarrray() As Byte Dim restoredPlainText() As Byte Dim RSA As New RSACryptoServiceProvider Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load xmlprivatekey = RSA.ToXmlString(True) xmlpublickey = RSA.ToXmlString(False) End Sub Public Sub Encrypt() RSA.FromXmlString(xmlpublickey) Dim msg As String = "" msg = txtoriginal.Text Dim ue As New UnicodeEncoding plaintextarray = ue.GetBytes(msg) hpertextarrray = RSA.Encrypt(plaintextarray, False) txtcypher.Clear() For i As Integer = 0 To hpertextarrray.Length - 1 txtcypher.Text = txtcypher.Text + hpertextarrray(i).ToString() Next End Sub Public Sub Decrypt() RSA.FromXmlString(xmlprivatekey) restoredPlainText = RSA.Decrypt(hpertextarrray, False) txtRestrored.Clear() Dim str As Byte For i As Integer = 0 To restoredPlainText.Length - 1 str = restoredPlainText(i).ToString() txtRestrored.Text += GetChar(str, 1) Next End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Encrypt() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Decrypt() End Sub End Class thanks in advance lavan kumar

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      OK. After taking a look at your code, I'd say scrap it and rewrite it in a more organized fashion, modeling it from this example[^].

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups