找回密码
 加入
搜索
查看: 1257|回复: 6

_StringEncrypt的问题

[复制链接]
发表于 2009-6-23 15:58:52 | 显示全部楼层 |阅读模式
本帖最后由 liangxm 于 2009-6-23 17:13 编辑

测试代码如下,我看@error返回是0,说明加密没出错,但为什么我的$passwordsmi是空呢?qqq

#include <String.au3>
$user=InputBox("用户名","第一步"&@crlf&"请输入运行程序的指定用户名")
  $passwords=InputBox("密码","第二步"&@crlf&"请输入运行程序的用户密码","","*")
   
        Msgbox(0,"1" , $user)
   Msgbox(0,"2" , $passwords)
   
   $passwordsmi = _StringEncrypt(1,$passwords,"bbb")
  Msgbox(0,"error" , @error)
   $user2 = _StringEncrypt(1,$user,"bbb")
     Msgbox(0,"error" , @error)

    Msgbox(0,"3" , $passwordsmi)
        Msgbox(0,"4" , $user2)
 楼主| 发表于 2009-6-23 16:04:53 | 显示全部楼层
哦,搜了一下
老生重谈了。。。用ANSI编译。。。

我看看先~
 楼主| 发表于 2009-6-23 16:25:02 | 显示全部楼层
奇怪,我添加了
#AutoIt3Wrapper_UseAnsi=y
脚本也用文本打开,用ansi保存后编译了,但还是为空,不知道怎么回事。。。。
 楼主| 发表于 2009-6-23 16:51:39 | 显示全部楼层
用了这个可以了。。。。

Func _StringEncryptW($i_Encrypt, $s_EncryptText, $s_EncryptPassword, $i_EncryptLevel = 1)

    If $i_Encrypt <> 0 And $i_Encrypt <> 1 Then

        SetError(1)

        Return ''

    ElseIf $s_EncryptText = '' Or $s_EncryptPassword = '' Then

        SetError(1)

        Return ''

    Else

        If Number($i_EncryptLevel) <= 0 Or Int($i_EncryptLevel) <> $i_EncryptLevel Then $i_EncryptLevel = 1

        Local $v_EncryptModified

        Local $i_EncryptCountH

        Local $i_EncryptCountG

        Local $v_EncryptSwap

        Local $av_EncryptBox[256][2]

        Local $i_EncryptCountA

        Local $i_EncryptCountB

        Local $i_EncryptCountC

        Local $i_EncryptCountD

        Local $i_EncryptCountE

        Local $v_EncryptCipher

        Local $v_EncryptCipherBy

        If $i_Encrypt = 1 Then

            For $i_EncryptCountF = 0 To $i_EncryptLevel Step 1

                $i_EncryptCountG = ''

                $i_EncryptCountH = ''

                $v_EncryptModified = ''

                For $i_EncryptCountG = 1 To StringLen($s_EncryptText)

                    If $i_EncryptCountH = StringLen($s_EncryptPassword) Then

                        $i_EncryptCountH = 1

                    Else

                        $i_EncryptCountH += 1

                    EndIf

                    $v_EncryptModified = $v_EncryptModified & ChrW(BitXOR(AscW(StringMid($s_EncryptText, $i_EncryptCountG, 1)), AscW(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255))

                Next

                $s_EncryptText = $v_EncryptModified

                $i_EncryptCountA = ''

                $i_EncryptCountB = 0

                $i_EncryptCountC = ''

                $i_EncryptCountD = ''

                $i_EncryptCountE = ''

                $v_EncryptCipherBy = ''

                $v_EncryptCipher = ''

                $v_EncryptSwap = ''

                $av_EncryptBox = ''

                Local $av_EncryptBox[256][2]

                For $i_EncryptCountA = 0 To 255

                    $av_EncryptBox[$i_EncryptCountA][1] = AscW(StringMid($s_EncryptPassword, Mod($i_EncryptCountA, StringLen($s_EncryptPassword)) + 1, 1))

                    $av_EncryptBox[$i_EncryptCountA][0] = $i_EncryptCountA

                Next

                For $i_EncryptCountA = 0 To 255

                    $i_EncryptCountB = Mod(($i_EncryptCountB + $av_EncryptBox[$i_EncryptCountA][0] + $av_EncryptBox[$i_EncryptCountA][1]), 256)

                    $v_EncryptSwap = $av_EncryptBox[$i_EncryptCountA][0]

                    $av_EncryptBox[$i_EncryptCountA][0] = $av_EncryptBox[$i_EncryptCountB][0]

                    $av_EncryptBox[$i_EncryptCountB][0] = $v_EncryptSwap

                Next

                For $i_EncryptCountA = 1 To StringLen($s_EncryptText)

                    $i_EncryptCountC = Mod(($i_EncryptCountC + 1), 256)

                    $i_EncryptCountD = Mod(($i_EncryptCountD + $av_EncryptBox[$i_EncryptCountC][0]), 256)

                    $i_EncryptCountE = $av_EncryptBox[Mod(($av_EncryptBox[$i_EncryptCountC][0] + $av_EncryptBox[$i_EncryptCountD][0]), 256)][0]

                    $v_EncryptCipherBy = BitXOR(AscW(StringMid($s_EncryptText, $i_EncryptCountA, 1)), $i_EncryptCountE)

                    $v_EncryptCipher &= Hex($v_EncryptCipherBy, 2)

                Next

                $s_EncryptText = $v_EncryptCipher

            Next

        Else

            For $i_EncryptCountF = 0 To $i_EncryptLevel Step 1

                $i_EncryptCountB = 0

                $i_EncryptCountC = ''

                $i_EncryptCountD = ''

                $i_EncryptCountE = ''

                $v_EncryptCipherBy = ''

                $v_EncryptCipher = ''

                $v_EncryptSwap = ''

                $av_EncryptBox = ''

                Local $av_EncryptBox[256][2]

                For $i_EncryptCountA = 0 To 255

                    $av_EncryptBox[$i_EncryptCountA][1] = AscW(StringMid($s_EncryptPassword, Mod($i_EncryptCountA, StringLen($s_EncryptPassword)) + 1, 1))

                    $av_EncryptBox[$i_EncryptCountA][0] = $i_EncryptCountA

                Next

                For $i_EncryptCountA = 0 To 255

                    $i_EncryptCountB = Mod(($i_EncryptCountB + $av_EncryptBox[$i_EncryptCountA][0] + $av_EncryptBox[$i_EncryptCountA][1]), 256)

                    $v_EncryptSwap = $av_EncryptBox[$i_EncryptCountA][0]

                    $av_EncryptBox[$i_EncryptCountA][0] = $av_EncryptBox[$i_EncryptCountB][0]

                    $av_EncryptBox[$i_EncryptCountB][0] = $v_EncryptSwap

                Next

                For $i_EncryptCountA = 1 To StringLen($s_EncryptText) Step 2

                    $i_EncryptCountC = Mod(($i_EncryptCountC + 1), 256)

                    $i_EncryptCountD = Mod(($i_EncryptCountD + $av_EncryptBox[$i_EncryptCountC][0]), 256)

                    $i_EncryptCountE = $av_EncryptBox[Mod(($av_EncryptBox[$i_EncryptCountC][0] + $av_EncryptBox[$i_EncryptCountD][0]), 256)][0]

                    $v_EncryptCipherBy = BitXOR(Dec(StringMid($s_EncryptText, $i_EncryptCountA, 2)), $i_EncryptCountE)

                    $v_EncryptCipher = $v_EncryptCipher & ChrW($v_EncryptCipherBy)

                Next

                $s_EncryptText = $v_EncryptCipher

                $i_EncryptCountG = ''

                $i_EncryptCountH = ''

                $v_EncryptModified = ''

                For $i_EncryptCountG = 1 To StringLen($s_EncryptText)

                    If $i_EncryptCountH = StringLen($s_EncryptPassword) Then

                        $i_EncryptCountH = 1

                    Else

                        $i_EncryptCountH += 1

                    EndIf

                    $v_EncryptModified &= ChrW(BitXOR(AscW(StringMid($s_EncryptText, $i_EncryptCountG, 1)), AscW(StringMid($s_EncryptPassword, $i_EncryptCountH, 1)), 255))

                Next

                $s_EncryptText = $v_EncryptModified

            Next

        EndIf

        Return $s_EncryptText

    EndIf

EndFunc
发表于 2009-6-23 16:58:34 | 显示全部楼层
在au3文件上右键---编译脚本(带选项)编译为exe就行了

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2009-6-23 17:43:28 | 显示全部楼层
在au3文件上右键---编译脚本(带选项)编译为exe就行了
4100
lynfr8 发表于 2009-6-23 16:58



3q,我看了,我的是e文版的,好像没有你那个选项。。。
发表于 2009-6-23 18:30:55 | 显示全部楼层
路已经指出了,自己走吧
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-10 04:07 , Processed in 0.078857 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表