Simple Encryption...

ricky92

Member
Joined
Jan 13, 2007
Messages
13
Location
Naples, Italy
Programming Experience
Beginner
...that doesn't work well. Sometimes, it just changes a letter. But I don't understand why...
VB.NET:
    Dim input As String = "abcdefghigklmnopqrstuvwxyz0123456789,;.:-_@#°+]}[{^?'=)(/&%$£" & ChrW(34) & "!\|~<> "
    Dim outputs As String() = { _
        "s][1@£7>b2\}i:p;0o|&°z%/9t6$^w_4~?egy{#" & ChrW(34) & "(!)kdgm8n =+vrq'3xc-,.lha<u5f", _
        "l.b4=kv+ng1p{,-_em897^c" & ChrW(34) & "#o[|$h%(0u!a'w<}~\y@fs>°:xd;&£r)3/?izg6q] 5t2", _
        "\ol^!hb%?g(6fi0#@;{r~=[pgzw1/£" & ChrW(34) & "m}n<)us°>]a&_7tq42d5'3-,kc$8: vey.+|9x", _
        "mu$%0q]}xw'[(-|ny)o" & ChrW(34) & "{+gp=5_~ike!@&/^;8vb\?91dl:#7h3g.t£<c°6sf>z2,4r a", _
        "agdr£4[=?3f~/#v@{q\|7l+k-<!'9zc2s}igh$xe" & ChrW(34) & "n_;). (om5p&,8t]y:^0w>6b%°1u", _
        "1>n#y;:{£|,lacxh&g5iz0~k$qm'+p<4°(ro9u76st?3gvw" & ChrW(34) & "^.d!-=[@/)e]2f\8_ %}b", _
        "s8_f^l[}0a +m/1udrt];v" & ChrW(34) & ")7|-(hn'=kqiz@£°&woy,%#~5cpxg?{\4$9.b6e32!g>:<" _
    }

    Public Function encode(ByVal str As String) As String
        Dim outNum As Integer = CInt(Rnd() * (outputs.Length - 1))
        Dim out As String = outputs(outNum)

        Dim buffer As String = String.Empty
        For i As Integer = 0 To str.Length - 1
            If input.Contains(str(i)) Then
                buffer &= out(input.IndexOf(str(i)))
            Else
                buffer &= str(i)
            End If
        Next
        buffer &= String.Format("{0:00}", outNum)
        Return buffer
    End Function

    Public Function decode(ByVal str As String) As String
        Dim out As String = outputs(Convert.ToInt32(str.Substring(str.Length - 2)))
        str = str.Substring(0, str.Length - 2)
        Dim buffer As String = String.Empty
        For i As Integer = 0 To str.Length - 1
            If out.Contains(str(i)) Then
                buffer &= input(out.IndexOf(str(i)))
            Else
                buffer &= str(i)
            End If
        Next
        Return buffer
    End Function
Can someone help me?
 
Back
Top