Click here to Skip to main content
15,922,166 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionRun .Net ApplicationThrough INI File(Urgent) Pin
fahedakhter@hotmail.com28-Mar-07 23:42
fahedakhter@hotmail.com28-Mar-07 23:42 
AnswerRe: Run .Net ApplicationThrough INI File(Urgent) Pin
Tamimi - Code28-Mar-07 23:58
Tamimi - Code28-Mar-07 23:58 
AnswerRe: Run .Net ApplicationThrough INI File(Urgent) Pin
kubben29-Mar-07 3:13
kubben29-Mar-07 3:13 
AnswerRe: Run .Net ApplicationThrough INI File(Urgent) Pin
Vasudevan Deepak Kumar29-Mar-07 6:15
Vasudevan Deepak Kumar29-Mar-07 6:15 
QuestionEncryption and decryption........... [modified] Pin
Member 387988128-Mar-07 22:24
Member 387988128-Mar-07 22:24 
AnswerRe: Encryption and decryption........... Pin
CPallini28-Mar-07 22:50
mveCPallini28-Mar-07 22:50 
AnswerRe: Encryption and decryption........... Pin
Member 387988128-Mar-07 23:35
Member 387988128-Mar-07 23:35 
GeneralRe: Encryption and decryption........... [modified] Pin
JUNEYT29-Mar-07 0:48
JUNEYT29-Mar-07 0:48 
Here is code that is how you can encrypt and decrypt any strings. I didn't write it but got from one of other codeproject.com members. It is working fine. If you get any error message, you should consider in using different ENCRYPT_KEY or ENCRYPT_VECTOR until the error message disappears. I assume that you know how to use a class sample inside code. I have given you a sample below how to use it. WTF | :WTF:

Dim MyEncryption as Encryption
Dim EStr as String = "Fish can't think but fish knows everything"

Messagebox.show("Encrypted Format:" +  MyEncryption.toBase64(Estr))
Messagebox.show("Decrypted Format:" +  MyEncryprion.toBase32(Estr))


Imports System.Text
Imports System.Security.Cryptography

Public Class Encryption
#Region "Public Routines"
    const ENCRYPT_KEY AS STRING = "TEST"
    const ENCRYPT_VECTOR AS STRING = "CODEPRJT"

    Public Shared Function ToBase64(ByVal sDataToEncrypt As String) As String
        Dim stream As System.IO.MemoryStream = New System.IO.MemoryStream
        Dim key As Byte() = Encoding.Default.GetBytes(ENCRYPT_KEY.PadRight(24, Chr(0)))
        Dim Vector As Byte() = Encoding.Default.GetBytes(ENCRYPT_VECTOR.PadRight(8, Chr(0)))

        Dim des As TripleDESCryptoServiceProvider = New TripleDESCryptoServiceProvider
        Dim cryptoStream As CryptoStream = New CryptoStream(stream, des.CreateEncryptor(key, Vector), CryptoStreamMode.Write)

        Dim Input() As Byte = Encoding.Default.GetBytes(sDataToEncrypt)

        cryptoStream.Write(Input, 0, Input.Length)
        cryptoStream.FlushFinalBlock()

        Return Convert.ToBase64String(stream.ToArray())
    End Function

    Public Shared Function ToBase32(ByVal sDataToDecrypt As String) As String
        Dim stream As System.IO.MemoryStream = New System.IO.MemoryStream
        Dim key As Byte() = Encoding.Default.GetBytes(ENCRYPT_KEY.PadRight(24, Chr(0)))
        Dim Vector As Byte() = Encoding.Default.GetBytes(ENCRYPT_VECTOR.PadRight(8, Chr(0)))

        Dim des As TripleDESCryptoServiceProvider = New TripleDESCryptoServiceProvider
        Dim cryptoStream As CryptoStream = New CryptoStream(stream, des.CreateDecryptor(key, Vector), CryptoStreamMode.Write)

        Dim Input() As Byte = Convert.FromBase64String(sDataToDecrypt)

        cryptoStream.Write(Input, 0, Input.Length)
        cryptoStream.FlushFinalBlock()

        Return Encoding.Default.GetString(stream.ToArray())
    End Function
#End Region
End Class



-- modified at 6:53 Thursday 29th March, 2007


What a curious mind needs to discover knowledge is noting else than a pin-hole.


GeneralRe: Encryption and decryption........... Pin
Member 387988129-Mar-07 1:12
Member 387988129-Mar-07 1:12 
GeneralRe: Encryption and decryption........... Pin
JUNEYT29-Mar-07 1:44
JUNEYT29-Mar-07 1:44 
GeneralRe: Encryption and decryption........... Pin
Member 387988129-Mar-07 2:00
Member 387988129-Mar-07 2:00 
GeneralRe: Encryption and decryption........... Pin
JUNEYT29-Mar-07 2:27
JUNEYT29-Mar-07 2:27 
GeneralRe: Encryption and decryption........... Pin
Member 387988129-Mar-07 3:06
Member 387988129-Mar-07 3:06 
GeneralRe: Encryption and decryption........... Pin
JUNEYT29-Mar-07 3:31
JUNEYT29-Mar-07 3:31 
GeneralRe: Encryption and decryption........... Pin
Member 387988129-Mar-07 3:51
Member 387988129-Mar-07 3:51 
GeneralRe: Encryption and decryption........... Pin
Member 387988129-Mar-07 3:56
Member 387988129-Mar-07 3:56 
GeneralRe: Encryption and decryption........... Pin
JUNEYT29-Mar-07 4:04
JUNEYT29-Mar-07 4:04 
GeneralRe: Encryption and decryption........... Pin
Member 387988129-Mar-07 4:09
Member 387988129-Mar-07 4:09 
GeneralRe: Encryption and decryption........... Pin
JUNEYT29-Mar-07 5:51
JUNEYT29-Mar-07 5:51 
GeneralRe: Encryption and decryption........... Pin
Member 387988129-Mar-07 17:50
Member 387988129-Mar-07 17:50 
GeneralRe: Encryption and decryption........... Pin
JUNEYT29-Mar-07 21:08
JUNEYT29-Mar-07 21:08 
AnswerRe: Encryption and decryption........... Pin
Vasudevan Deepak Kumar29-Mar-07 6:16
Vasudevan Deepak Kumar29-Mar-07 6:16 
GeneralRe: Encryption and decryption........... Pin
Member 387988129-Mar-07 19:19
Member 387988129-Mar-07 19:19 
QuestionWord document Pin
scorp_scorp28-Mar-07 19:41
scorp_scorp28-Mar-07 19:41 
AnswerRe: Word document Pin
A*****28-Mar-07 19:53
A*****28-Mar-07 19:53 

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.