找回密码
 加入
搜索
查看: 20744|回复: 7

[AU3基础] 哪位大侠给个根据时间生成随机字母和数字自定义函数,谢谢~

  [复制链接]
发表于 2014-1-22 14:56:10 | 显示全部楼层 |阅读模式
RT,非常感激,谢谢啦~
发表于 2014-1-23 11:45:10 | 显示全部楼层
起码给个格式参考下嘛
 楼主| 发表于 2014-1-23 20:09:12 | 显示全部楼层
就是生成随机字母串,或字符串加数字就行,根据系统时间。我也没思路。。。
发表于 2014-1-23 21:08:15 | 显示全部楼层
你试一下,是不是这样子
$time=@YEAR&@MON&@MDAY&@HOUR&@MIN
MsgBox(0,"","当前时间是:"&$time&@CRLF&"当前时间字符串:"&pc_au3_pswd($time))

Func pc_au3_pswd($char)
        Local $code, $ascx
        $code='var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";'&@CRLF
$code&='var base64DecodeChars = new Array('&@CRLF
$code&='-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,'&@CRLF
$code&='-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,'&@CRLF
$code&='-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,'&@CRLF
$code&='52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,'&@CRLF
$code&='-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,'&@CRLF
$code&='15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,'&@CRLF
$code&='-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,'&@CRLF
$code&='41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1);'&@CRLF
$code&='function base64encode(str) {'&@CRLF
$code&='var out, i, len;'&@CRLF
$code&='var c1, c2, c3;'&@CRLF
$code&='len = str.length;'&@CRLF
$code&='i = 0;'&@CRLF
$code&='out = "";'&@CRLF
$code&='while(i < len) {'&@CRLF
$code&='c1 = str.charCodeAt(i++) & 0xff;'&@CRLF
$code&='if(i == len)'&@CRLF
$code&='{'&@CRLF
$code&='out += base64EncodeChars.charAt(c1 >> 2);'&@CRLF
$code&='out += base64EncodeChars.charAt((c1 & 0x3) << 4);'&@CRLF
$code&='out += "==";'&@CRLF
$code&='break;'&@CRLF
$code&='}'&@CRLF
$code&='c2 = str.charCodeAt(i++);'&@CRLF
$code&='if(i == len)'&@CRLF
$code&='{'&@CRLF
$code&='out += base64EncodeChars.charAt(c1 >> 2);'&@CRLF
$code&='out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4));'&@CRLF
$code&='out += base64EncodeChars.charAt((c2 & 0xF) << 2);'&@CRLF
$code&='out += "=";'&@CRLF
$code&='break;'&@CRLF
$code&='}'&@CRLF
$code&='c3 = str.charCodeAt(i++);'&@CRLF
$code&='out += base64EncodeChars.charAt(c1 >> 2);'&@CRLF
$code&='out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4));'&@CRLF
$code&='out += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6));'&@CRLF
$code&='out += base64EncodeChars.charAt(c3 & 0x3F);'&@CRLF
$code&='}'&@CRLF
$code&='return out;'&@CRLF
$code&='}'&@CRLF
$code&='function base64decode(str) {'&@CRLF
$code&='var c1, c2, c3, c4;'&@CRLF
$code&='var i, len, out;'&@CRLF
$code&='len = str.length;'&@CRLF
$code&='i = 0;'&@CRLF
$code&='out = "";'&@CRLF
$code&='while(i < len) {'&@CRLF
$code&='do {'&@CRLF
$code&='c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff];'&@CRLF
$code&='} while(i < len && c1 == -1);'&@CRLF
$code&='if(c1 == -1)'&@CRLF
$code&='break;'&@CRLF
$code&='do {'&@CRLF
$code&='c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff];'&@CRLF
$code&='} while(i < len && c2 == -1);'&@CRLF
$code&='if(c2 == -1)'&@CRLF
$code&='break;'&@CRLF
$code&='out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4));'&@CRLF
$code&='do {'&@CRLF
$code&='c3 = str.charCodeAt(i++) & 0xff;'&@CRLF
$code&='if(c3 == 61)'&@CRLF
$code&='return out;'&@CRLF
$code&='c3 = base64DecodeChars[c3];'&@CRLF
$code&='} while(i < len && c3 == -1);'&@CRLF
$code&='if(c3 == -1)'&@CRLF
$code&='break;'&@CRLF
$code&='out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2));'&@CRLF
$code&='do {'&@CRLF
$code&='c4 = str.charCodeAt(i++) & 0xff;'&@CRLF
$code&='if(c4 == 61)'&@CRLF
$code&='return out;'&@CRLF
$code&='c4 = base64DecodeChars[c4];'&@CRLF
$code&='} while(i < len && c4 == -1);'&@CRLF
$code&='if(c4 == -1)'&@CRLF
$code&='break;'&@CRLF
$code&='out += String.fromCharCode(((c3 & 0x03) << 6) | c4);'&@CRLF
$code&='}'&@CRLF
$code&='return out;'&@CRLF
$code&='}'&@CRLF
$code&='var hex_chr = "0123456789abcdef";'&@CRLF
$code&='function rhex(num)'&@CRLF
$code&='{'&@CRLF
$code&=' str = "";'&@CRLF
$code&=' for(j = 0; j <= 3; j++)'&@CRLF
$code&=' str += hex_chr.charAt((num >> (j * 8 + 4)) & 0x0F) +'&@CRLF
$code&=' hex_chr.charAt((num >> (j * 8)) & 0x0F);'&@CRLF
$code&=' return str;'&@CRLF
$code&='}'&@CRLF
$code&='function str2blks_MD5(str)'&@CRLF
$code&='{'&@CRLF
$code&=' nblk = ((str.length + 8) >> 6) + 1;'&@CRLF
$code&=' blks = new Array(nblk * 16);'&@CRLF
$code&=' for(i = 0; i < nblk * 16; i++) blks = 0;'&@CRLF
$code&=' for(i = 0; i < str.length; i++)'&@CRLF
$code&=' blks[i >> 2] |= str.charCodeAt(i) << ((i % 4) * 8);'&@CRLF
$code&=' blks[i >> 2] |= 0x80 << ((i % 4) * 8);'&@CRLF
$code&=' blks[nblk * 16 - 2] = str.length * 8;'&@CRLF
$code&=' return blks;'&@CRLF
$code&='}'&@CRLF
$code&='function add(x, y)'&@CRLF
$code&='{'&@CRLF
$code&=' var lsw = (x & 0xFFFF) + (y & 0xFFFF);'&@CRLF
$code&=' var msw = (x >> 16) + (y >> 16) + (lsw >> 16);'&@CRLF
$code&=' return (msw << 16) | (lsw & 0xFFFF);'&@CRLF
$code&='}'&@CRLF
$code&='function rol(num, cnt)'&@CRLF
$code&='{'&@CRLF
$code&=' return (num << cnt) | (num >>> (32 - cnt));'&@CRLF
$code&='}'&@CRLF
$code&='function cmn(q, a, b, x, s, t)'&@CRLF
$code&='{'&@CRLF
$code&=' return add(rol(add(add(a, q), add(x, t)), s), b);'&@CRLF
$code&='}'&@CRLF
$code&='function ff(a, b, c, d, x, s, t)'&@CRLF
$code&='{'&@CRLF
$code&=' return cmn((b & c) | ((~b) & d), a, b, x, s, t);'&@CRLF
$code&='}'&@CRLF
$code&='function gg(a, b, c, d, x, s, t)'&@CRLF
$code&='{'&@CRLF
$code&=' return cmn((b & d) | (c & (~d)), a, b, x, s, t);'&@CRLF
$code&='}'&@CRLF
$code&='function hh(a, b, c, d, x, s, t)'&@CRLF
$code&='{'&@CRLF
$code&=' return cmn(b ^ c ^ d, a, b, x, s, t);'&@CRLF
$code&='}'&@CRLF
$code&='function ii(a, b, c, d, x, s, t)'&@CRLF
$code&='{'&@CRLF
$code&=' return cmn(c ^ (b | (~d)), a, b, x, s, t);'&@CRLF
$code&='}'&@CRLF
$code&='function MD5(str)'&@CRLF
$code&='{'&@CRLF
$code&=' x = str2blks_MD5(str);'&@CRLF
$code&=' var a = 1732584193;'&@CRLF
$code&=' var b = -271733879;'&@CRLF
$code&=' var c = -1732584194;'&@CRLF
$code&=' var d = 271733878;'&@CRLF
$code&=' for(i = 0; i < x.length; i += 16)'&@CRLF
$code&=' {'&@CRLF
$code&=' var olda = a;'&@CRLF
$code&=' var oldb = b;'&@CRLF
$code&=' var oldc = c;'&@CRLF
$code&=' var oldd = d;'&@CRLF
$code&=' a = ff(a, b, c, d, x[i+ 0], 7 , -680876936);'&@CRLF
$code&=' d = ff(d, a, b, c, x[i+ 1], 12, -389564586);'&@CRLF
$code&=' c = ff(c, d, a, b, x[i+ 2], 17, 606105819);'&@CRLF
$code&=' b = ff(b, c, d, a, x[i+ 3], 22, -1044525330);'&@CRLF
$code&=' a = ff(a, b, c, d, x[i+ 4], 7 , -176418897);'&@CRLF
$code&=' d = ff(d, a, b, c, x[i+ 5], 12, 1200080426);'&@CRLF
$code&=' c = ff(c, d, a, b, x[i+ 6], 17, -1473231341);'&@CRLF
$code&=' b = ff(b, c, d, a, x[i+ 7], 22, -45705983);'&@CRLF
$code&=' a = ff(a, b, c, d, x[i+ 8], 7 , 1770035416);'&@CRLF
$code&=' d = ff(d, a, b, c, x[i+ 9], 12, -1958414417);'&@CRLF
$code&=' c = ff(c, d, a, b, x[i+10], 17, -42063);'&@CRLF
$code&=' b = ff(b, c, d, a, x[i+11], 22, -1990404162);'&@CRLF
$code&=' a = ff(a, b, c, d, x[i+12], 7 , 1804603682);'&@CRLF
$code&=' d = ff(d, a, b, c, x[i+13], 12, -40341101);'&@CRLF
$code&=' c = ff(c, d, a, b, x[i+14], 17, -1502002290);'&@CRLF
$code&=' b = ff(b, c, d, a, x[i+15], 22, 1236535329);'&@CRLF
$code&=' a = gg(a, b, c, d, x[i+ 1], 5 , -165796510);'&@CRLF
$code&=' d = gg(d, a, b, c, x[i+ 6], 9 , -1069501632);'&@CRLF
$code&=' c = gg(c, d, a, b, x[i+11], 14, 643717713);'&@CRLF
$code&=' b = gg(b, c, d, a, x[i+ 0], 20, -373897302);'&@CRLF
$code&=' a = gg(a, b, c, d, x[i+ 5], 5 , -701558691);'&@CRLF
$code&=' d = gg(d, a, b, c, x[i+10], 9 , 38016083);'&@CRLF
$code&=' c = gg(c, d, a, b, x[i+15], 14, -660478335);'&@CRLF
$code&=' b = gg(b, c, d, a, x[i+ 4], 20, -405537848);'&@CRLF
$code&=' a = gg(a, b, c, d, x[i+ 9], 5 , 568446438);'&@CRLF
$code&=' d = gg(d, a, b, c, x[i+14], 9 , -1019803690);'&@CRLF
$code&=' c = gg(c, d, a, b, x[i+ 3], 14, -187363961);'&@CRLF
$code&=' b = gg(b, c, d, a, x[i+ 8], 20, 1163531501);'&@CRLF
$code&=' a = gg(a, b, c, d, x[i+13], 5 , -1444681467);'&@CRLF
$code&=' d = gg(d, a, b, c, x[i+ 2], 9 , -51403784);'&@CRLF
$code&=' c = gg(c, d, a, b, x[i+ 7], 14, 1735328473);'&@CRLF
$code&=' b = gg(b, c, d, a, x[i+12], 20, -1926607734);'&@CRLF
$code&=' a = hh(a, b, c, d, x[i+ 5], 4 , -378558);'&@CRLF
$code&=' d = hh(d, a, b, c, x[i+ 8], 11, -2022574463);'&@CRLF
$code&=' c = hh(c, d, a, b, x[i+11], 16, 1839030562);'&@CRLF
$code&=' b = hh(b, c, d, a, x[i+14], 23, -35309556);'&@CRLF
$code&=' a = hh(a, b, c, d, x[i+ 1], 4 , -1530992060);'&@CRLF
$code&=' d = hh(d, a, b, c, x[i+ 4], 11, 1272893353);'&@CRLF
$code&=' c = hh(c, d, a, b, x[i+ 7], 16, -155497632);'&@CRLF
$code&=' b = hh(b, c, d, a, x[i+10], 23, -1094730640);'&@CRLF
$code&=' a = hh(a, b, c, d, x[i+13], 4 , 681279174);'&@CRLF
$code&=' d = hh(d, a, b, c, x[i+ 0], 11, -358537222);'&@CRLF
$code&=' c = hh(c, d, a, b, x[i+ 3], 16, -722521979);'&@CRLF
$code&=' b = hh(b, c, d, a, x[i+ 6], 23, 76029189);'&@CRLF
$code&=' a = hh(a, b, c, d, x[i+ 9], 4 , -640364487);'&@CRLF
$code&=' d = hh(d, a, b, c, x[i+12], 11, -421815835);'&@CRLF
$code&=' c = hh(c, d, a, b, x[i+15], 16, 530742520);'&@CRLF
$code&=' b = hh(b, c, d, a, x[i+ 2], 23, -995338651);'&@CRLF
$code&=' a = ii(a, b, c, d, x[i+ 0], 6 , -198630844);'&@CRLF
$code&=' d = ii(d, a, b, c, x[i+ 7], 10, 1126891415);'&@CRLF
$code&=' c = ii(c, d, a, b, x[i+14], 15, -1416354905);'&@CRLF
$code&=' b = ii(b, c, d, a, x[i+ 5], 21, -57434055);'&@CRLF
$code&=' a = ii(a, b, c, d, x[i+12], 6 , 1700485571);'&@CRLF
$code&=' d = ii(d, a, b, c, x[i+ 3], 10, -1894986606);'&@CRLF
$code&=' c = ii(c, d, a, b, x[i+10], 15, -1051523);'&@CRLF
$code&=' b = ii(b, c, d, a, x[i+ 1], 21, -2054922799);'&@CRLF
$code&=' a = ii(a, b, c, d, x[i+ 8], 6 , 1873313359);'&@CRLF
$code&=' d = ii(d, a, b, c, x[i+15], 10, -30611744);'&@CRLF
$code&=' c = ii(c, d, a, b, x[i+ 6], 15, -1560198380);'&@CRLF
$code&=' b = ii(b, c, d, a, x[i+13], 21, 1309151649);'&@CRLF
$code&=' a = ii(a, b, c, d, x[i+ 4], 6 , -145523070);'&@CRLF
$code&=' d = ii(d, a, b, c, x[i+11], 10, -1120210379);'&@CRLF
$code&=' c = ii(c, d, a, b, x[i+ 2], 15, 718787259);'&@CRLF
$code&=' b = ii(b, c, d, a, x[i+ 9], 21, -343485551);'&@CRLF
$code&=' a = add(a, olda);'&@CRLF
$code&=' b = add(b, oldb);'&@CRLF
$code&=' c = add(c, oldc);'&@CRLF
$code&=' d = add(d, oldd);'&@CRLF
$code&=' }'&@CRLF
$code&=' return rhex(b);'&@CRLF
$code&='}'&@CRLF
$code&='function pcpswd(str) {'&@CRLF
$code&='return base64encode(MD5(str));'&@CRLF
$code&='}'&@CRLF
                $VBS = ObjCreate("ScriptControl")
        $VBS.language = "JScript"
        $VBS.addcode($code)
        $ascx = $VBS.Run("pcpswd", $char)
        Return $ascx
EndFunc   
发表于 2014-1-23 21:23:38 | 显示全部楼层
4楼辛苦了~
发表于 2014-1-23 23:00:47 | 显示全部楼层
MD5?
发表于 2014-1-24 08:46:27 | 显示全部楼层
如果要与时间关联,可以考虑直接把时间作为整数转换为N进制数


MsgBox(0, '', _62Hex(TimerInit(), 48))

Func _62Hex($iValue, $iHex)
        If $iHex < 2 Or $iHex > 65 Then
                Return SetError(1, 0, "")
        EndIf

        Local Const $KEY = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-+@"

        Local $iMod, $sResult

        While $iValue
                $iMod = Mod($iValue, $iHex)
                $sResult = StringMid($KEY, $iMod + 1, 1) & $sResult

                $iValue = Int($iValue / $iHex)

        WEnd

        ;Return StringFormat("(%d)%s", $iHex, $sResult)
        Return $sResult
EndFunc   ;==>_62Hex
发表于 2014-1-25 10:26:08 | 显示全部楼层
这题目问的,有根据怎么叫随机,要无法还原吗,那就散列化
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-12-24 01:10 , Processed in 0.078855 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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