1. Este site usa cookies. Ao continuar a usar este site está a concordar com o nosso uso de cookies. Saber Mais.

Ajuda a interpretar código em JavaScript

Discussão em 'Web Development' iniciada por jorginho-, 17 de Junho de 2008. (Respostas: 0; Visualizações: 733)

  1. Código:
    <SCRIPT LANGUAGE=[COLOR=#3366cc]"JavaScript"[/COLOR]>
    <!-- Begin
    [COLOR=#003366][B]var[/B][/COLOR] params=[COLOR=#003366][B]new[/B][/COLOR] Array[COLOR=#66cc66]([/COLOR]4[COLOR=#66cc66])[/COLOR];
    [COLOR=#003366][B]var[/B][/COLOR] alpha=[COLOR=#3366cc]"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI"[/COLOR];
    [COLOR=#003366][B]function[/B][/COLOR] check[COLOR=#66cc66]([/COLOR]form[COLOR=#66cc66])[/COLOR] [COLOR=#66cc66]{[/COLOR]
    which=form.[COLOR=#006600]memlist[/COLOR].[COLOR=#006600]selectedIndex[/COLOR];
    choice = form.[COLOR=#006600]memlist[/COLOR].[COLOR=#006600]options[/COLOR][COLOR=#66cc66][[/COLOR]which[COLOR=#66cc66]][/COLOR].[COLOR=#006600]value[/COLOR]+[COLOR=#3366cc]"|"[/COLOR];
    [COLOR=#000066][B]if[/B][/COLOR] [COLOR=#66cc66]([/COLOR]choice==[COLOR=#3366cc]"x|"[/COLOR][COLOR=#66cc66])[/COLOR] [COLOR=#66cc66]{[/COLOR]
    [COLOR=#000066]alert[/COLOR][COLOR=#66cc66]([/COLOR][COLOR=#3366cc]"Please Select Your Name From The List"[/COLOR][COLOR=#66cc66])[/COLOR];
    [COLOR=#000066][B]return[/B][/COLOR];
    [COLOR=#66cc66]}[/COLOR]
    p=0;
    [COLOR=#000066][B]for[/B][/COLOR] [COLOR=#66cc66]([/COLOR]i=0;i<3;i++[COLOR=#66cc66])[/COLOR] [COLOR=#66cc66]{[/COLOR]
    a=choice.[COLOR=#006600]indexOf[/COLOR][COLOR=#66cc66]([/COLOR][COLOR=#3366cc]"|"[/COLOR],p[COLOR=#66cc66])[/COLOR];
    params[COLOR=#66cc66][[/COLOR]i[COLOR=#66cc66]][/COLOR]=choice.[COLOR=#006600]substring[/COLOR][COLOR=#66cc66]([/COLOR]a,p[COLOR=#66cc66])[/COLOR];
    p=a+1;
    [COLOR=#66cc66]}[/COLOR]
    h1=makehash[COLOR=#66cc66]([/COLOR]form.[COLOR=#006600]pass[/COLOR].[COLOR=#006600]value[/COLOR],3[COLOR=#66cc66])[/COLOR];
    h2=makehash[COLOR=#66cc66]([/COLOR]form.[COLOR=#006600]pass[/COLOR].[COLOR=#006600]value[/COLOR],10[COLOR=#66cc66])[/COLOR]+[COLOR=#3366cc]" "[/COLOR];
    [COLOR=#000066][B]if[/B][/COLOR] [COLOR=#66cc66]([/COLOR]h1!=params[COLOR=#66cc66][[/COLOR]1[COLOR=#66cc66]][/COLOR][COLOR=#66cc66])[/COLOR] [COLOR=#66cc66]{[/COLOR]
    [COLOR=#000066]alert[/COLOR][COLOR=#66cc66]([/COLOR][COLOR=#3366cc]"Palavra Chave Incorrecta!"[/COLOR][COLOR=#66cc66])[/COLOR]; [COLOR=#000066][B]return[/B][/COLOR]; [COLOR=#66cc66]}[/COLOR];
    [COLOR=#003366][B]var[/B][/COLOR] page=[COLOR=#3366cc]""[/COLOR];
    [COLOR=#000066][B]for[/B][/COLOR] [COLOR=#66cc66]([/COLOR][COLOR=#003366][B]var[/B][/COLOR] i=0;i<8;i++[COLOR=#66cc66])[/COLOR] [COLOR=#66cc66]{[/COLOR]
    letter=params[COLOR=#66cc66][[/COLOR]2[COLOR=#66cc66]][/COLOR].[COLOR=#006600]substring[/COLOR][COLOR=#66cc66]([/COLOR]i,i+1[COLOR=#66cc66])[/COLOR]
    ul=letter.[COLOR=#006600]toUpperCase[/COLOR][COLOR=#66cc66]([/COLOR][COLOR=#66cc66])[/COLOR];
    a=alpha.[COLOR=#006600]indexOf[/COLOR][COLOR=#66cc66]([/COLOR]ul,0[COLOR=#66cc66])[/COLOR];
    a-=[COLOR=#66cc66]([/COLOR]h2.[COLOR=#006600]substring[/COLOR][COLOR=#66cc66]([/COLOR]i,i+1[COLOR=#66cc66])[/COLOR]*1[COLOR=#66cc66])[/COLOR];
    [COLOR=#000066][B]if[/B][/COLOR] [COLOR=#66cc66]([/COLOR]a<0[COLOR=#66cc66])[/COLOR] a+=26;
    page+=alpha.[COLOR=#006600]substring[/COLOR][COLOR=#66cc66]([/COLOR]a,a+1[COLOR=#66cc66])[/COLOR]; [COLOR=#66cc66]}[/COLOR];
    top.[COLOR=#006600]location[/COLOR]=page.[COLOR=#006600]toLowerCase[/COLOR][COLOR=#66cc66]([/COLOR][COLOR=#66cc66])[/COLOR]+[COLOR=#3366cc]".html"[/COLOR];
    [COLOR=#66cc66]}[/COLOR]
    [COLOR=#003366][B]function[/B][/COLOR] makehash[COLOR=#66cc66]([/COLOR]pw,mult[COLOR=#66cc66])[/COLOR] [COLOR=#66cc66]{[/COLOR]
    pass=pw.[COLOR=#006600]toUpperCase[/COLOR][COLOR=#66cc66]([/COLOR][COLOR=#66cc66])[/COLOR];
    hash=0;
    [COLOR=#000066][B]for[/B][/COLOR] [COLOR=#66cc66]([/COLOR]i=0;i<8;i++[COLOR=#66cc66])[/COLOR] [COLOR=#66cc66]{[/COLOR]
    letter=pass.[COLOR=#006600]substring[/COLOR][COLOR=#66cc66]([/COLOR]i,i+1[COLOR=#66cc66])[/COLOR];
    c=alpha.[COLOR=#006600]indexOf[/COLOR][COLOR=#66cc66]([/COLOR]letter,0[COLOR=#66cc66])[/COLOR]+1;
    hash=hash*mult+c;
    [COLOR=#66cc66]}[/COLOR]
    [COLOR=#000066][B]return[/B][/COLOR][COLOR=#66cc66]([/COLOR]hash[COLOR=#66cc66])[/COLOR];
    [COLOR=#66cc66]}[/COLOR]
    [COLOR=#009900][I]// End -->[/I][/COLOR]
    </script>
    Ao que me parece, ele cria as passwords mas não consigo saber quais são. Alguma ajuda? Estou mesmo entalado...
     
    Última edição pelo moderador: 22 de Junho de 2008

Partilhar esta Página