Click here to Skip to main content
15,896,063 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Calculate total hours between two times.............. Pin
Member 387988119-Mar-07 22:45
Member 387988119-Mar-07 22:45 
GeneralTry This Then.. Pin
The ANZAC19-Mar-07 23:10
The ANZAC19-Mar-07 23:10 
AnswerRe: Calculate total hours between two times.............. Pin
The ANZAC19-Mar-07 22:49
The ANZAC19-Mar-07 22:49 
GeneralRe: Calculate total hours between two times.............. Pin
Member 387988119-Mar-07 22:55
Member 387988119-Mar-07 22:55 
AnswerRe: Calculate total hours between two times.............. [modified] Pin
TwoFaced20-Mar-07 7:12
TwoFaced20-Mar-07 7:12 
Questionchange string back to byte Pin
angelagke19-Mar-07 18:36
angelagke19-Mar-07 18:36 
AnswerRe: change string back to byte Pin
Dave Kreskowiak20-Mar-07 4:35
mveDave Kreskowiak20-Mar-07 4:35 
AnswerRe: change string back to byte Pin
Kschuler20-Mar-07 8:00
Kschuler20-Mar-07 8:00 
Here is a class I found and modified to encrypt/decrypt. Hope it helps you.

Imports System.IO
Imports System.Text
Imports System.Security.Cryptography

Public Class Encryption64
    Private key() As Byte = {}
    Private IV() As Byte = {&H11, &H22, &H33, &H44, &H55, &H66, &H77, &H88}

    Public Function Decrypt(ByVal strToDecrypt As String, _
                            ByVal strEncryptionKey As String) As String
        '*******************************************************
        '   This function will:                                 
        '       - Accept a string and encryption key            
        '       - Decrypt and return the string                 
        '                                                       
        '   NOTE:  If strToDecrypt is from a query string,      
        '          the Request.QueryString will have replaced   
        '          any '+' characters with a space.             
        '*******************************************************
        Dim inputByteArray(strToDecrypt.Length) As Byte
        Dim des As New DESCryptoServiceProvider()
        Dim ms As New MemoryStream()

        Try
            'Set key
            key = System.Text.Encoding.UTF8.GetBytes(Left(strEncryptionKey, 8))

            'Convert input string into byte array
            inputByteArray = Convert.FromBase64String(strToDecrypt)

            'Perform the decryption with memory stream object
            Dim cs As New CryptoStream(ms, des.CreateDecryptor(key, IV), CryptoStreamMode.Write)
            cs.Write(inputByteArray, 0, inputByteArray.Length)
            cs.FlushFinalBlock()

            'Convert and return decrypted byte array in memory stream into string
            Dim encoding As System.Text.Encoding = System.Text.Encoding.UTF8
            Return encoding.GetString(ms.ToArray())

        Catch e As Exception
            Return e.Message
        End Try
    End Function

    Public Function Encrypt(ByVal strToEncrypt As String, _
                            ByVal strEncryptionKey As String) As String
        '***************************************************
        '   This function will:                             
        '       - Accept a string and encryption key        
        '       - Encrypt and return the string             
        '***************************************************
        Dim des As New DESCryptoServiceProvider()
        Dim ms As New MemoryStream()

        Try
            'Set key
            key = System.Text.Encoding.UTF8.GetBytes(Left(strEncryptionKey, 8))

            'Convert input string into byte array
            Dim inputByteArray() As Byte = Encoding.UTF8.GetBytes(strToEncrypt)

            'Perform the encryption with memory stream object
            Dim cs As New CryptoStream(ms, des.CreateEncryptor(key, IV), CryptoStreamMode.Write)
            cs.Write(inputByteArray, 0, inputByteArray.Length)
            cs.FlushFinalBlock()

            'Convert and return encrypted byte array in memory stream into string
            Return Convert.ToBase64String(ms.ToArray())

        Catch e As Exception
            Return e.Message
        End Try
    End Function

End Class

AnswerRe: change string back to byte Pin
emiaj14-Apr-07 7:45
emiaj14-Apr-07 7:45 
QuestionReturn a value when an exeception happens Pin
steve_rm19-Mar-07 18:29
steve_rm19-Mar-07 18:29 
AnswerRe: Return a value when an exeception happens Pin
Christian Graus19-Mar-07 19:04
protectorChristian Graus19-Mar-07 19:04 
AnswerRe: Return a value when an exeception happens Pin
Tirthadip19-Mar-07 19:15
Tirthadip19-Mar-07 19:15 
GeneralRe: Return a value when an exeception happens Pin
Dave Kreskowiak20-Mar-07 4:32
mveDave Kreskowiak20-Mar-07 4:32 
AnswerRe: Return a value when an exeception happens Pin
Johan Hakkesteegt21-Mar-07 4:26
Johan Hakkesteegt21-Mar-07 4:26 
QuestionMake usercontrol that doesn't steal focus Pin
TwoFaced19-Mar-07 14:06
TwoFaced19-Mar-07 14:06 
AnswerRe: Make usercontrol that doesn't steal focus Pin
Christian Graus19-Mar-07 16:19
protectorChristian Graus19-Mar-07 16:19 
GeneralRe: Make usercontrol that doesn't steal focus Pin
TwoFaced19-Mar-07 19:11
TwoFaced19-Mar-07 19:11 
QuestionMouse scroll wheel and MSHFlexGrid Pin
Barry True19-Mar-07 10:20
Barry True19-Mar-07 10:20 
AnswerRe: Mouse scroll wheel and MSHFlexGrid Pin
Dave Kreskowiak19-Mar-07 10:36
mveDave Kreskowiak19-Mar-07 10:36 
GeneralRe: Mouse scroll wheel and MSHFlexGrid Pin
Barry True27-Apr-07 8:29
Barry True27-Apr-07 8:29 
QuestionWhich .DLL is used to delete IE7 cache? Pin
gacman19-Mar-07 9:35
gacman19-Mar-07 9:35 
Questiondataset.acceptchange method.. [modified] Pin
manni_n19-Mar-07 7:59
manni_n19-Mar-07 7:59 
AnswerRe: dataset.acceptchange method.. Pin
Dave Kreskowiak19-Mar-07 8:51
mveDave Kreskowiak19-Mar-07 8:51 
GeneralRe: dataset.acceptchange method.. Pin
manni_n19-Mar-07 9:04
manni_n19-Mar-07 9:04 
GeneralRe: dataset.acceptchange method.. Pin
Dave Kreskowiak19-Mar-07 9:27
mveDave Kreskowiak19-Mar-07 9:27 

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.