235 messaggi dal 27 aprile 2009
Ciao a tutti, in questi giorni stavo cercando qualcosa per fare decrypt e encrypt per creare delle license.
Ho trovato questo :
    Public Const key As String = "414c657353614e44724f614d6532334e6f76524d42526531393736"
    Public Function LicenseId(ByVal key As String) As String
        Dim str As String
        Try
            Dim str2 As String = encrypt(String.Format("{1}{0}{2}{0}{3}", New Object() {"||", email, appName, appVer}), key)
            str = encrypt(String.Format("{1}{0}{2}", "||", encrypt(str2, deviceId), deviceId), key)
        Catch exception1 As Exception
            Dim ex As Exception = exception1
            str = Nothing

        End Try
        Return str
    End Function


 Public Shared Function decrypt(ByVal value As Byte(), ByVal key As String) As Byte()
        Dim buffer As Byte() = StringToBytes(key)
        Dim buffer3 As Byte() = Array.CreateInstance(GetType(Byte), value.Length)
        Dim num3 As Integer = (value.Length - 1)
        Dim i As Integer = 0
        Do While (i <= num3)
            Dim num As Integer = (value(i) - buffer((i Mod buffer.Length)))
            buffer3(i) = Conversions.ToByte(Interaction.IIf((num < 0), (num + &HFF), num))
            i += 1
        Loop
        Return buffer3
    End Function

    Public Shared Function encrypt(ByVal value As Byte(), ByVal key As String) As Byte()
        Dim buffer As Byte() = StringToBytes(key)
        Dim buffer3 As Byte() = Array.CreateInstance(GetType(Byte), value.Length)
        Dim num3 As Integer = (value.Length - 1)
        Dim i As Integer = 0
        Do While (i <= num3)
            Dim num As Integer = (value(i) + buffer((i Mod buffer.Length)))
            buffer3(i) = Conversions.ToByte(Interaction.IIf((num > &HFF), (num Mod &HFF), num))
            i += 1
        Loop
        Return buffer3
    End Function

    Public Shared Function StringToBytes(ByVal s As String) As Byte()
        Dim buffer As Byte() = Array.CreateInstance(GetType(Byte), s.get_Length)
        Dim length As Integer = buffer.Length
        Dim i As Integer = 1
        Do While (i <= length)
            buffer((i - 1)) = Strings.Asc(Strings.Mid(s, i, 1))
            i += 1
        Loop
        Return buffer
    End Function



ma non capisco :

1.Come funziona
2. Ho provato ad lanciarlo e mi dice ;
Value of type 'String' cannot be converted to '1-dimensional
su questa riga :
encrypt(String.Format("{1}{0}{2}{0}{3}", New Object() {"||"
3. E questo errore che nn capisco perchè:
Error3'get_Length' is not a member of 'String'.


Grazie per tutti gli aiuti che mi darete.
Ciao a tutti.
12 messaggi dal 17 febbraio 2002
1) Il parametro richiesto da encrypt è byte() cioè un array di byte, l'istruzione passa una stringa.
2) il medotodo .get_lenght per una stringa non esiste, usa invece .lenght

Attenzione non c'è solo questo.
E' un vero pasticcio e secondo me non funzionano affatto, sembrano derivare da una conversione automatica c#->vb o comunque scritte assolutamente male.
Curiosità: dove hai trovato queste routines?

Torna al forum | Feed RSS

ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.
Community
Ultimi messaggi
UTENTI ONLINE
In primo piano

I più letti di oggi

Media
In evidenza
MISC