方法很多,如取得ASCII码后,再取异或。

解决方案 »

  1.   

    呵呵,最简单的算法,用ASC函数取得每个字符的编码,然后随便你怎么着,比如XOR了,简单四则运算了,规则随你定了。只是要注意,汉字取到的是负数。
      

  2.   

    取得ASCII码后,给具体的值!!!
      

  3.   

    这样吧!你的薪水我拿了!ha,ha,ha....
      

  4.   

    asc("字符串"),结果为整型,但ASC()函数只取首个字符,需要做个循环。然后你自己想怎样就怎样了,呵呵。
      

  5.   

    Private Sub Command1_Click()
    Dim aa As String
    Dim bb As Integer, i As Integer
    aa = "CSDN"
    For i = 1 To Len(aa)
       bb = bb + Asc(Mid(aa, i, 1))
    Next
    MsgBox bb
    End Sub
      

  6.   

    'One Test Example:Private Sub Form_Load()Dim StrSource As String
    StrSource = "CSDN"
    ConvertToInt (StrSource)Debug.Print ConvertToInt(StrSource)End SubPublic Function ConvertToInt(StrSource As String) As LongDim strTarget As String
    Dim i As IntegerstrTarget = ""
    For i = 1 To Len(StrSource)
        strTarget = strTarget & Asc(Mid(StrSource, i, 1))
    Next i
    ConvertToInt = CLng(strTarget)End Function
      

  7.   

    'One Test Example(Add):Private Sub Form_Load()Dim StrSource As String
    StrSource = "CSDN"
    ConvertToInt (StrSource)Debug.Print ConvertToInt(StrSource)End SubPublic Function ConvertToInt(StrSource As String) As IntegerDim intTarget As Integer
    Dim i As IntegerintTarget = 0
    For i = 1 To Len(StrSource)
        intTarget = intTarget + Asc(Mid(StrSource, i, 1))
    Next iEnd Function
      

  8.   

    上面的函数少返回:
    加:
    ConvertToInt = intTarget
      

  9.   

    Private Const c_strKeyCode As String = "laskdjf;HPOIUFHIudlj985kjn9d9sdfjsfhlhasdkjkoodsf.d" & _
                                           "LJjdl;lh;hID7d8%fr6fpm9s9O9f8hdojfs9&()dfo9sajfo99d" & _
                                           "Lkf45%$tr89j786554tf54t6vuiL:KOioJiH((kOuOj(85$RFfd" & _
                                           "%$^UJlhsdf87dhfiohad98sfh9h978*JOPddD:FLSJDdadsgfad" & _
                                           "98as7dhfa98sdnfhKU*H(ISHFD*D&ASRRSRASD>KM(FN()(*EDdf"Private byteCode(1 To 256) As BytePublic Function CreateSerialNumber(Key As String, SerialLength As Integer) As String
        If Key = "" Then Err.Raise 10000, , "关键字符串为空"
        If SerialLength < 8 Then Err.Raise 10001, , "生成序列号必须在 8 位以上"
        If SerialLength > 32 Then Err.Raise 10002, , "生成序列号必须在 32 位以下"
        Call InitCodes
        Dim intInitCounter As Integer
        Dim intCounter As Integer
        Dim strInitCode As String
        Dim strInitKey As String
        Dim strCombCode As String
        Dim strSerialNumber As String
        Dim intKeyNumber As Integer
        Do
            For intCounter = SerialLength + intInitCounter To 256 Step intInitCounter + 1
                strInitCode = strInitCode & CStr(byteCode(intCounter))
            Next intCounter
            intInitCounter = intInitCounter + 1
        Loop Until Len(strInitCode) >= 2 * SerialLength
        strInitCode = Left(strInitCode, 2 * SerialLength)
        For intCounter = 1 To Len(Key)
            intKeyNumber = intKeyNumber + CInt(Right(CStr(Asc(Mid(Key, intCounter, 1))), 1))
        Next intCounter
        Do
            For intCounter = Len(Key) To 1 Step -1
                strInitKey = strInitKey & CStr(Abs(Asc(Mid(Key, intCounter, 1))) * CLng(intKeyNumber))
            Next intCounter
        Loop Until Len(strInitKey) >= 2 * SerialLength
        strInitKey = Left(strInitKey, 2 * SerialLength)
        For intCounter = 1 To SerialLength * 2 Step 2
            strCombCode = strCombCode & Chr(CLng(Mid(strInitKey, intCounter, 2)) Xor _
                                            CLng(Mid(strInitCode, intCounter, 2)))
        Next intCounter
        For intCounter = 1 To SerialLength
            Dim byteCodeAsc As Byte
            byteCodeAsc = CByte(Asc(Mid(strCombCode, intCounter, 1)))
            If byteCodeAsc <= 25 Then
                strSerialNumber = strSerialNumber & Chr(byteCodeAsc + 65)
            ElseIf byteCodeAsc <= 51 Then
                strSerialNumber = strSerialNumber & Chr(byteCodeAsc + 71)
            ElseIf byteCodeAsc <= 61 Then
                strSerialNumber = strSerialNumber & Chr(byteCodeAsc - 4)
            ElseIf byteCodeAsc <= 71 Then
                strSerialNumber = strSerialNumber & Chr(byteCodeAsc - 14)
            ElseIf byteCodeAsc <= 96 Then
                strSerialNumber = strSerialNumber & Chr(byteCodeAsc - 7)
            Else
                strSerialNumber = strSerialNumber & Chr(byteCodeAsc + 10)
            End If
            If (Asc(Right(strSerialNumber, 1)) < 48) Or (Asc(Right(strSerialNumber, 1)) > 57 And _
                Asc(Right(strSerialNumber, 1)) < 65) Or (Asc(Right(strSerialNumber, 1)) > 90 And _
                Asc(Right(strSerialNumber, 1)) < 97) Or (Asc(Right(strSerialNumber, 1)) > 122) Then
                strSerialNumber = Mid(strSerialNumber, 1, Len(strSerialNumber) - 1) & "2"
            End If
        Next intCounter
        CreateSerialNumber = strSerialNumber
        
    End FunctionPrivate Sub InitCodes()
        Dim intCounter As Integer
        For intCounter = 1 To 256
            byteCode(intCounter) = Asc(Mid(c_strKeyCode, intCounter, 1))
        Next intCounter
    End Sub用这个试试 CreateSerialNumber(KeyWord, Length)
    可以生成8到32位的注册码,不可逆算法