473,406 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Encypt/decrypt of a string

Is there a quick and easy way to encrypt and decrypt a string in vb.net

Nov 20 '05 #1
5 20776
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
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
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
* "=?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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Giovanni pepe | last post by:
I must Crypt and Decrypt String with password Exists examples ? Thank you
4
by: Hrvoje Voda | last post by:
Does anyone knows a good example of how to encrypt/decrypt a string? Hrcko
6
by: Carolyn Vo | last post by:
Hi there! I have a string that was encrypted in Java using the classes DESKeySpec, SecretKeyFactory, SecretKey, and Cipher. It looks like using the SecretKeyFactory puts a transparent layer on...
1
by: news.microsoft.com | last post by:
I want to have one machine encypt a string value(in memory not disk), and then pass that new value to another machine, where it will be decrypted back to its original value. I have no idea on...
1
by: Peter | last post by:
Has anyone made a simple tripple des encryption function? I'm looking for a function to pass a string into with a password and generate an encrypted output. That's it. IE. Public Function...
2
by: DazedAndConfused | last post by:
Can someone point me to some code that will encypt/decrypt flat files? Thank you in advance!
8
by: toupeira23 | last post by:
Hello, I'm trying to encrypt passwords in my app. After discovering that there's no simple function to do this, I wrote a wrapper class which decodes a string using UTF8, encrypts it with...
4
by: hohans | last post by:
Hi all, I have an encryption class that encrypts and decrypts password using TripleDESCryptoServiceProvider. It was written originally in framework 1.0 and been working fine. And those...
0
by: Hannibal111111 | last post by:
I found this code on a site for doing string encryption/decryption. The string will encrypt fine, but I get this error when I try to decrypt. Any idea why? I posted the code below. The error...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.