Products
Services
Contact Us

Scripts: asp :: ASP.NET encryption :: Library Article #4

Developer's Section

Encrypt a String in ASP.NET
By: Erobo Team Member

Hire a Developer for Related Work / Installation | $55 hr
Rating:  | Rate It:   
Average Votes: (3295)
Favorites:

learn to encrypt a string in ASP.NET

Learn to encrypt a string in ASP.NET

Building the Encryptor

 Code Snippet 1
  
Private Function EncryptTripleDES(ByVal Plaintext As String,
                                                                          ByVal Key As String) As String
    'Create Cryptography Objects
    Dim DES As New System.Security.Cryptography.TripleDESCryptoServiceProvider
    'Create Hash type MD5
    Dim hashMD5 As New System.Security.Cryptography.MD5CryptoServiceProvider
    'Assign key
    DES.Key = hashMD5.ComputeHash 
                                        (System.Text.ASCIIEncoding.ASCII.GetBytes(Key))

    DES.Mode = System.Security.Cryptography.CipherMode.ECB

    Dim DESEncrypt As System.Security.Cryptography.ICryptoTransform

    DESEncrypt = DES.CreateEncryptor()

    Dim Buffer() As Byte 

    Buffer = System.Text.ASCIIEncoding.ASCII.GetBytes(Plaintext)

    EncryptTripleDES = Convert.ToBase64String(
                             DESEncrypt.TransformFinalBlock(Buffer, 0,Buffer.Length))

End Function




See other Scripts in ASP.NET encryption

Submit Your Scripts:

If you would like to have your ASP & ASP.NET scripts published in this section please fill out
the form below:
*Your Name or Username:
Home Town:
*Email:
*Description and Code:
*Enter Code shown
to the right:

[ Refresh Image ]