请会C语言或PHP的大大帮下忙哈,转个函数成AU3,谢谢 (已解决)
本帖最后由 llztt 于 2012-2-13 10:02 编辑有个河南网通的用户名算法,不过是C语言的,可否会C的帮忙转成AU3的,谢谢啊
详情见附件
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Application->NormalizeTopMosts();
Application->MessageBox(" 新乡水星科技\n\n\n QQ:511597049\n E-mial:zzbinfo@163.com", "关于" );
Application->RestoreTopMosts();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if(Edit1->Text.Length()>0&Edit1->Text.Length()<128)
{
Edit2->Text = "2:"+EnCode(Edit1->Text);
}else
{
ShowMessage(" 用户名错误 !");
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TForm1::EnCode(AnsiString string)
{
char cas_str[]="9012345678abcdeABCDEFGHIJKLMNfghijklmnUVWXYZxyzuvwopqrstOPQRST";
int cas_str_buffer;
int cas_esi = 37;
char src_str,dec_str="";
int k=0;
int cas_eax,cas_edx;
div_t x;
unsigned inti,j;
cas_str_buffer=25;
cas_str_buffer=35;
cas_str_buffer=182;
cas_str_buffer=236;
cas_str_buffer=43;
cas_str_buffer=41;
cas_str_buffer=53;
cas_str_buffer=18;
cas_str_buffer=226;
cas_str_buffer=215;
cas_str_buffer=24;
cas_str_buffer=117;
cas_str_buffer=35;
cas_str_buffer=201;
cas_str_buffer=52;
cas_str_buffer=17;
strcpy(src_str,string.c_str());
for ( i=0;i<strlen(src_str);i++)
{
for(j=0;j<strlen(cas_str);j++)
{
if (src_str==cas_str){
if(i<16)
cas_eax=cas_str_buffer;
else {
x=div(i,16);
cas_eax=cas_str_buffer ;
}
cas_edx=cas_esi+cas_esi*2 ;
cas_eax=cas_eax^cas_edx;
cas_eax=cas_eax^k;
cas_eax=cas_eax+j;
x = div(cas_eax,62);
dec_str=cas_str;
cas_edx=x.rem ;
cas_esi=cas_esi^(cas_edx+9433);
break;
}
}
if( dec_str==NULL)
dec_str=src_str;
k=k+5;
}
string=dec_str;
return string;
}
void __fastcall TForm1::Button3Click(TObject *Sender)
{
if(Edit2->Text.Length()>0&Edit2->Text.Length()<128)
{
Edit1->Text = DeCode(Edit2->Text);
}else
{
ShowMessage(" 用户名错误 !");
}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TForm1::DeCode(AnsiString string)
{
char src_temp[]="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
if(string.SubString(1,2)=="2:")string=string.SubString(3,string.Length()-2);
AnsiString TempString="";
AnsiString TempString1="";
for(int j=0;j<string.Length()+1;j++)
{
for(int i=0;i<62;i++)
{
TempString = TempString1 + AnsiString(src_temp);
if(EnCode(TempString)== string.SubString(1,j))
{
TempString1=TempString;
break;
}
}
}
return TempString1;
}
再附上PHP代码,会PHP的也能转换下<?php
/*
* 演示地址: http://citic.info/liht/wangtong.php
*/
$src_str = $_REQUEST["inputkey"];// 输入框获取你的网通帐号,
$ustr = "9012345678abcdeABCDEFGHIJKLMNfghijklmnUVWXYZxyzuvwopqrstOPQRST";
$yinzi = "25-35-182-236-43-41-53-18-226-215-24-117-35-201-52-17";
$yinzi = array_reverse(explode("-", $yinzi));
$l = 37;
$k = 0;
for ($i = 0; $i < strlen($src_str); $i++) {
for ($j = 0; $j < strlen($ustr); $j++) {
if ($src_str[$i] == $ustr[$j]) {
if ($i < 16) {
$u1 = $yinzi[$i];
} else {
$x = $i % 16;
$u1 = $yinzi[$x];
}
$u1 = (($u1 ^ ($l * 3)) ^ $k) + $j;
$x = $u1 % 62;
$dec_str[$i] = $ustr[$x];
$l = $l ^ ($x +9433);
break;
}
}
if ($dec_str[$i] === "")
$dec_str[$i] = $ustr[$i];
$k = $k +5;
}
if ($dec_str!=null)
$dec_str = '2:' . implode($dec_str);
echo "转换后的网通账号为:" . $dec_str;
?> 我把PHP的转了一下,不过貌似在幂运算时报错了,好像是超出AU3的运算范围了? 传送门:
http://www.autoitx.com/forum.php?mod=redirect&goto=findpost&ptid=20954&pid=253771&fromuid=7639113 呵呵,原来多此一举了,非常感谢
页:
[1]