By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,417 Members | 904 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,417 IT Pros & Developers. It's quick & easy.

Encypt/decrypt of a string

P: n/a
Is there a quick and easy way to encrypt and decrypt a string in vb.net

Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi,

http://www.franklins.net/dotnet/dpapiHelper.zip

Ken
------------------------
"Tony" <To**@discussions.microsoft.com> wrote in message
news:77**********************************@microsof t.com...
Is there a quick and easy way to encrypt and decrypt a string in vb.net
Nov 20 '05 #2

P: n/a
Hi Tony,

A lot methods, have a look at MSDN and search for Rijndael (one
methode)however the easiest to get the right encryption method and not the
encryption of ascii and images and stuff like that.

I hope this helps?

Cor
Nov 20 '05 #3

P: n/a
hi,
this is my simple? (expandible) poly-engine crypter for string

http://www.codeproject.com/dotnet/StackCrypt.asp

good job
Marcello

"Cantelmo Software" del Geom. Marcello Cantelmo
Sito Web: www.cantelmosoftware.com (in continuous modernization)
E-Mail: in**@cantelmosoftware.com
"Tony" <To**@discussions.microsoft.com> ha scritto nel messaggio
news:77**********************************@microsof t.com...
Is there a quick and easy way to encrypt and decrypt a string in vb.net

Nov 20 '05 #4

P: n/a
* "=?Utf-8?B?VG9ueQ==?=" <To**@discussions.microsoft.com> scripsit:
Is there a quick and easy way to encrypt and decrypt a string in vb.net


Did you take a look in the archives?

<URL:http://groups.google.de/groups?q=dotnet+encrypt+decrypt+string>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
<URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 20 '05 #5

P: n/a
Tony,

There are many options here, but a simple solution is:

<code (VB.NET) >
Public Class Crypto

' TAKEN FROM MS KB Q317535

Public Shared Function EncryptTripleDES(ByVal sIn As String, ByVal sKey As
String) As String
Dim DES As New
System.Security.Cryptography.TripleDESCryptoServic eProvider
Dim hashMD5 As New System.Security.Cryptography.MD5CryptoServiceProvi der

' scramble the key
sKey = ScrambleKey(sKey)
' Compute the MD5 hash.
DES.Key =
hashMD5.ComputeHash(System.Text.ASCIIEncoding.ASCI I.GetBytes(sKey))
' Set the cipher mode.
DES.Mode = System.Security.Cryptography.CipherMode.ECB
' Create the encryptor.
Dim DESEncrypt As System.Security.Cryptography.ICryptoTransform =
DES.CreateEncryptor()
' Get a byte array of the string.
Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(sIn)
' Transform and return the string.
Return Convert.ToBase64String(DESEncrypt.TransformFinalBl ock(Buffer, 0,
Buffer.Length))
End Function

Public Shared Function DecryptTripleDES(ByVal sOut As String, ByVal sKey
As String) As String
Dim DES As New
System.Security.Cryptography.TripleDESCryptoServic eProvider
Dim hashMD5 As New System.Security.Cryptography.MD5CryptoServiceProvi der

' scramble the key
sKey = ScrambleKey(sKey)
' Compute the MD5 hash.
DES.Key =
hashMD5.ComputeHash(System.Text.ASCIIEncoding.ASCI I.GetBytes(sKey))
' Set the cipher mode.
DES.Mode = System.Security.Cryptography.CipherMode.ECB
' Create the decryptor.
Dim DESDecrypt As System.Security.Cryptography.ICryptoTransform =
DES.CreateDecryptor()
Dim Buffer As Byte() = Convert.FromBase64String(sOut)
' Transform and return the string.
Return
System.Text.ASCIIEncoding.ASCII.GetString(DESDecry pt.TransformFinalBlock(Buf
fer, 0, Buffer.Length))
End Function

Private Shared Function ScrambleKey(ByVal v_strKey As String) As String

Dim sbKey As New System.Text.StringBuilder
Dim intPtr As Integer
For intPtr = 1 To v_strKey.Length
Dim intIn As Integer = v_strKey.Length - intPtr + 1
sbKey.Append(Mid(v_strKey, intIn, 1))
Next

Dim strKey As String = sbKey.ToString

Return sbKey.ToString

End Function

End Class
</code>
-Sam Matzen
"Tony" <To**@discussions.microsoft.com> wrote in message
news:77**********************************@microsof t.com...
Is there a quick and easy way to encrypt and decrypt a string in vb.net

Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.