Click here to Skip to main content
15,913,610 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Executing the content of a String Pin
JosBerb14-Nov-07 0:11
JosBerb14-Nov-07 0:11 
AnswerRe: Executing the content of a String Pin
nlarson1113-Nov-07 16:37
nlarson1113-Nov-07 16:37 
GeneralRe: Executing the content of a String Pin
JosBerb14-Nov-07 0:19
JosBerb14-Nov-07 0:19 
QuestionEncryption Pin
mpavas13-Nov-07 3:53
mpavas13-Nov-07 3:53 
AnswerRe: Encryption Pin
AliAmjad13-Nov-07 5:39
AliAmjad13-Nov-07 5:39 
AnswerRe: Encryption Pin
Ocean4713-Nov-07 7:13
Ocean4713-Nov-07 7:13 
GeneralRe: Encryption Pin
mpavas13-Nov-07 19:20
mpavas13-Nov-07 19:20 
AnswerRe: Encryption Pin
Steven J Jowett13-Nov-07 22:41
Steven J Jowett13-Nov-07 22:41 
Below is an encryption/decryption class I have written and use.
To Encrypt, pass the the encrypt method the text to encrypt and an encryption key. As a result a string is returned with the encrypted text.

To decrypt pass the encrypted text to the decrypt method along with the original encrytion key and as a result you should now have the original text returned by the method.

Public Class Cryptography<br />
<br />
    Public Shared Function Encrypt(ByVal Text As String, ByVal Key As String) As String<br />
        Dim sEncrypted As String = ""<br />
        Dim iKey As Integer = 0<br />
        If Key.Trim.Length = 0 Then Throw New Exception("An encryption key is required")<br />
<br />
        For iChar As Integer = 0 To Text.Trim.Length - 1<br />
            Dim iTextChar As Integer = Asc(Text.Substring(iChar, 1))<br />
            Dim iKeyChar As Integer = Asc(Key.Substring(iKey, 1))<br />
            Dim iCharacterIndex As Integer = iTextChar + iKeyChar + iChar<br />
<br />
            While iCharacterIndex > 255<br />
                iCharacterIndex = iCharacterIndex - 255<br />
            End While<br />
<br />
            sEncrypted &= Chr(iCharacterIndex)<br />
            iKey += 1<br />
            If iKey > (Key.Trim.Length - 1) Then iKey = 0<br />
        Next<br />
        Return sEncrypted<br />
<br />
    End Function<br />
<br />
    Public Shared Function Decrypt(ByVal EncryptedText As String, ByVal Key As String) As String<br />
        Dim sDecrypted As String = ""<br />
        Dim iKey As Integer = 0<br />
        If Key.Trim.Length = 0 Then Throw New Exception("An encryption key is required")<br />
<br />
        For iChar As Integer = 0 To EncryptedText.Trim.Length - 1<br />
            Dim iTextChar As Integer = Asc(EncryptedText.Substring(iChar, 1))<br />
            Dim iKeyChar As Integer = Asc(Key.Substring(iKey, 1))<br />
            Dim iCharacterIndex As Integer = iTextChar - iKeyChar - iChar<br />
<br />
            While iCharacterIndex < 1<br />
                iCharacterIndex = iCharacterIndex + 255<br />
            End While<br />
<br />
            sDecrypted &= Chr(iCharacterIndex)<br />
            iKey += 1<br />
            If iKey > (Key.Trim.Length - 1) Then iKey = 0<br />
        Next<br />
        Return sDecrypted<br />
<br />
    End Function<br />
<br />
End Class


Regards

Steve Jowett
-------------------------
Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'

GeneralRe: Encryption Pin
Mark Churchill17-Dec-07 14:47
Mark Churchill17-Dec-07 14:47 
QuestionPopulate web page Pin
mcnewsxp13-Nov-07 3:48
mcnewsxp13-Nov-07 3:48 
Questiondifficult to handle datagridview with keyboard Pin
eyes200713-Nov-07 3:23
eyes200713-Nov-07 3:23 
QuestionError creating window handle Pin
Steven J Jowett13-Nov-07 1:17
Steven J Jowett13-Nov-07 1:17 
AnswerRe: Error creating window handle Pin
Steven J Jowett13-Nov-07 22:46
Steven J Jowett13-Nov-07 22:46 
QuestionCOM, Marshal, GetActiveObject Pin
Rheinflut199513-Nov-07 1:15
Rheinflut199513-Nov-07 1:15 
QuestionReference of VB6 COM & Activex components in VB.net setup : Need urgent help [modified] Pin
nishkarsh_k12-Nov-07 23:44
nishkarsh_k12-Nov-07 23:44 
AnswerRe: Reference of VB6 COM & Activex components in VB.net setup : Need urgent help Pin
Pankaj - Joshi13-Nov-07 0:30
Pankaj - Joshi13-Nov-07 0:30 
QuestionAcessing the Registry. Pin
SekharOne12-Nov-07 22:58
SekharOne12-Nov-07 22:58 
AnswerRe: Acessing the Registry. Pin
Christian Graus12-Nov-07 23:40
protectorChristian Graus12-Nov-07 23:40 
QuestionHow to speed up drop down of a combobox type column in a datagridview Pin
SekharOne12-Nov-07 22:52
SekharOne12-Nov-07 22:52 
AnswerRe: How to speed up drop down of a combobox type column in a datagridview Pin
Christian Graus12-Nov-07 23:40
protectorChristian Graus12-Nov-07 23:40 
GeneralRe: How to speed up drop down of a combobox type column in a datagridview Pin
SekharOne13-Nov-07 0:32
SekharOne13-Nov-07 0:32 
Questionnow a can read text file line by line but how to split it [modified] Pin
abdullah Hejory12-Nov-07 22:26
abdullah Hejory12-Nov-07 22:26 
AnswerRe: now a can read text file line by line but how to split it Pin
Christian Graus12-Nov-07 23:43
protectorChristian Graus12-Nov-07 23:43 
GeneralRe: now a can read text file line by line but how to split it Pin
abdullah Hejory13-Nov-07 0:22
abdullah Hejory13-Nov-07 0:22 
GeneralRe: now a can read text file line by line but how to split it Pin
Christian Graus13-Nov-07 0:24
protectorChristian Graus13-Nov-07 0:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.