Click here to Skip to main content
15,899,754 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionRequest for help Pin
gbaii14-Sep-05 7:16
gbaii14-Sep-05 7:16 
AnswerRe: Request for help Pin
Christian Graus14-Sep-05 11:33
protectorChristian Graus14-Sep-05 11:33 
AnswerRe: Request for help Pin
Gulfraz Khan16-Sep-05 7:29
Gulfraz Khan16-Sep-05 7:29 
AnswerRe: Request for help Pin
gbaii16-Sep-05 7:31
gbaii16-Sep-05 7:31 
QuestionFrozen Window Pin
johnjsm14-Sep-05 4:12
johnjsm14-Sep-05 4:12 
AnswerRe: Frozen Window Pin
Dave Kreskowiak14-Sep-05 4:38
mveDave Kreskowiak14-Sep-05 4:38 
QuestionConnection String Pin
kenexcelon14-Sep-05 4:06
kenexcelon14-Sep-05 4:06 
AnswerRe: Connection String Pin
shoaibnawaz15-Sep-05 20:05
shoaibnawaz15-Sep-05 20:05 
The Following function will solve your problem.
First Argument requirs string as "E" to Encrypt and "D" to Decrypt.
Second Argument is Key to Encryption the same key will be used to decrypt to orignal matter.
Third string is what you want to encrypt and then back to decrypt.

Function crypt(Action As String, Key As String, Src As String) As String
Dim Count As Integer, KeyPos As Integer, KeyLen As Integer, SrcAsc As Integer, dest As String, offset As Integer, TmpSrcAsc, SrcPos
KeyLen = Len(Key)

If Action = "E" Then
    Randomize
    offset = (Rnd * 10000 Mod 255) + 1

    dest = Hex$(offset)  ' problem with "offset" of single digit hex numbers
    ' when decodeing, decode procedure is looking for 2 digits, whereis lower number produce single digit hex numbers (ie 1,2,3,12...)
    If Len(dest) = 1 Then   ' adds 0 in front of single digit hex numbers
        dest = "0" + dest
    End If

    For SrcPos = 1 To Len(Src)
        SrcAsc = (Asc(Mid$(Src, SrcPos, 1)) + offset) Mod 255
        If KeyPos < KeyLen Then KeyPos = KeyPos + 1 Else KeyPos = 1
        'Fill Dest$ with HEX representation of Encrypted field
        'Hex used to keep nasties such as eof or lf from mangling stream
        'Use format$ to make Hex$ return " 0" instead of "0" when the same
        'values are Xor'ed together (Null) - keeps placeholder for decrypt
        SrcAsc = SrcAsc Xor Asc(Mid$(Key, KeyPos, 1))
        dest = dest + Format$(Hex$(SrcAsc), "@@")
        offset = SrcAsc

    Next

ElseIf Action = "D" Then
    offset = val("&H" + Left$(Src, 2))
    For SrcPos = 3 To Len(Src) Step 2
        SrcAsc = val("&H" + Trim(Mid$(Src, SrcPos, 2)))
        If KeyPos < KeyLen Then KeyPos = KeyPos + 1 Else KeyPos = 1
        TmpSrcAsc = SrcAsc Xor Asc(Mid$(Key, KeyPos, 1))
        If TmpSrcAsc <= offset Then
            TmpSrcAsc = 255 + TmpSrcAsc - offset
        Else
            TmpSrcAsc = TmpSrcAsc - offset
        End If
        dest = dest + Chr(TmpSrcAsc)
        offset = SrcAsc
    Next

End If
crypt = dest
End Function


Shoaib Nawaz

-- modified at 2:07 Friday 16th September, 2005
QuestionThe underlying connection was closed: The remote name could not be resolved. Pin
LeeOvEngland14-Sep-05 3:57
LeeOvEngland14-Sep-05 3:57 
QuestionSQL Restore and Backup Pin
kenexcelon14-Sep-05 3:48
kenexcelon14-Sep-05 3:48 
AnswerRe: SQL Restore and Backup Pin
Dave Kreskowiak14-Sep-05 4:27
mveDave Kreskowiak14-Sep-05 4:27 
AnswerRe: SQL Restore and Backup Pin
No-e14-Sep-05 4:32
No-e14-Sep-05 4:32 
AnswerRe: SQL Restore and Backup Pin
| Muhammad Waqas Butt |14-Sep-05 23:49
professional| Muhammad Waqas Butt |14-Sep-05 23:49 
GeneralRe: SQL Restore and Backup Pin
kenexcelon15-Sep-05 3:37
kenexcelon15-Sep-05 3:37 
QuestionCrystal Report Viewer Border Color Change Pin
prathiba_naresh14-Sep-05 3:42
prathiba_naresh14-Sep-05 3:42 
QuestionHow do set another folder than \bin for my assemblies when &quot;Local Copy&quot;... Pin
MaWeRic14-Sep-05 1:27
MaWeRic14-Sep-05 1:27 
QuestionDataAdapter.Update Pin
Adnan Yousuf14-Sep-05 0:09
Adnan Yousuf14-Sep-05 0:09 
QuestionVB.Net/Crystal Report 10 problem when installing program Pin
risepop13-Sep-05 21:26
risepop13-Sep-05 21:26 
Questionretrieving server date and time Pin
abhinish13-Sep-05 20:40
abhinish13-Sep-05 20:40 
AnswerRe: retrieving server date and time Pin
Dave Kreskowiak15-Sep-05 4:40
mveDave Kreskowiak15-Sep-05 4:40 
GeneralRe: retrieving server date and time Pin
dptalt16-Sep-05 2:52
dptalt16-Sep-05 2:52 
GeneralRe: retrieving server date and time Pin
Dave Kreskowiak16-Sep-05 3:15
mveDave Kreskowiak16-Sep-05 3:15 
GeneralRe: retrieving server date and time Pin
dptalt16-Sep-05 3:41
dptalt16-Sep-05 3:41 
QuestionOpening a Notepad file through opendialogbox in vb.net Pin
Anonymous13-Sep-05 20:34
Anonymous13-Sep-05 20:34 
AnswerRe: Opening a Notepad file through opendialogbox in vb.net Pin
Anonymous13-Sep-05 21:44
Anonymous13-Sep-05 21:44 

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.