[Delphi] Декод хеша при инвайтинге в группу.

Discussion in 'С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby' started by _DemiX_, 5 Oct 2010.

  1. _DemiX_

    _DemiX_ New Member

    Joined:
    25 May 2010
    Messages:
    51
    Likes Received:
    1
    Reputations:
    0
    Всем привет:)
    Я бы хотел узнать как декоднуть хеш при инвайтинге в группу ВКонтакте.
    Я даже предствления не имею, как это все реализовать.
    Помогите нубу:)
     
  2. AquaKlaster

    AquaKlaster Active Member

    Joined:
    9 Mar 2009
    Messages:
    0
    Likes Received:
    204
    Reputations:
    23
    Обычно, перевести код из JS на дельфи. Там пара циклов + реверс строки и выдерание частей строки.
     
  3. 090808

    090808 Member

    Joined:
    15 Mar 2009
    Messages:
    171
    Likes Received:
    46
    Reputations:
    10
    Code:
    function decode(s:string) :string;
    var
    hash:string;
    begin
    hash:='';
    hash:=hash+s[17];
    hash:=hash+s[16];
    hash:=hash+s[15];
    hash:=hash+s[14];
    hash:=hash+s[13];
    hash:=hash+s[12];
    hash:=hash+s[11];
    hash:=hash+s[10];
    hash:=hash+s[9];
    hash:=hash+s[8];
    hash:=hash+s[7];
    hash:=hash+s[6];
    hash:=hash+s[5];
    hash:=hash+s[25];
    hash:=hash+s[24];
    hash:=hash+s[23];
    hash:=hash+s[22];
    hash:=hash+s[21];
    result:=hash;
    end;
    
     
    1 person likes this.
  4. RedFern.89

    RedFern.89 Member

    Joined:
    20 Jan 2010
    Messages:
    575
    Likes Received:
    48
    Reputations:
    0
    Code:
    [I][COLOR=yellow]// ---- Раскодировка хэша ----[/I][/COLOR]
    [b][b]function[/b][/b] TidVKClient.DecodeHash([b]const[/b] Hash : [b]string[/b]) : [b]string[/b];
    [b]var[/b]
     Decchas : [b]string[/b];
     str : [b]string[/b];
     I : Integer;
     Len : integer;
    [b]begin[/b]
    
     str := Copy(Hash, 6, 12);
     Len := Length(str);
    
    [I][COLOR=yellow]// Я знаю, по-идиотски, но умнее было влом придумывать(([/I][/COLOR]
     [b]For[/b] I := 0 [b]To[/b] Length(str) -1 [b]do[/b]
     [b]begin[/b]
      Decchas := Decchas + str[len];
      Inc(len, -1);
     [b]end[/b];
    
     str := Copy(Hash, 21, Length(Hash) -5);
     str := str + Copy(Hash, 5, 1);
    
     Len := Length(str);
    
     [b]For[/b] I := 0 [b]To[/b] Length(str) -1 [b]do[/b]
     [b]begin[/b]
       Decchas := Decchas + str[len];
       Inc(len, -1);
     [b]end[/b];
    
     Result := Decchas;
    [b]end[/b];
    
    [I][COLOR=yellow]{ ***************************************************************************** }[/I][/COLOR]
    
    [I][COLOR=yellow]// ---- Раскодировка хэша стены ----[/I][/COLOR]
    [b]function[/b] TidVKClient.DecodeWallHash([b]const[/b] ASourceHash: [b]string[/b]): [b]string[/b];
    [b]var[/b]
      tmp : [b]string[/b];
      str : [b]string[/b];
      I   : Integer;
      Len : Integer;
    [b]begin[/b]
      tmp := ASourceHash;
      tmp := Copy(tmp, 5, 27);
    
      Len := Length(tmp);
    
      [b]For[/b] I := 0 [b]To[/b] Length(Tmp) -1 [b]do[/b]
      [b]begin[/b]
        str := str + tmp[len];
        Inc(len, -1);
      [b]end[/b];
    
      tmp := ASourceHash;
      tmp := Copy(tmp, 35, 5);
    
      Len := Length(Tmp);
    
      [b]For[/b] I := 0 [b]To[/b] Length(tmp) -1 [b]do[/b]
      [b]begin[/b]
        str := str + tmp[len];
        Inc(len, -1);
      [b]end[/b];
    
     Result := str;
    [b]end[/b];
    
    для инвайта юзай первую функцию)) )
     
    #4 RedFern.89, 5 Oct 2010
    Last edited: 9 Oct 2010
    1 person likes this.
  5. _DemiX_

    _DemiX_ New Member

    Joined:
    25 May 2010
    Messages:
    51
    Likes Received:
    1
    Reputations:
    0
    Спасибо всем:)
     
  6. need_million

    need_million Member

    Joined:
    29 Apr 2010
    Messages:
    158
    Likes Received:
    6
    Reputations:
    0
    переведите на C# плиз
     
  7. Kandi

    Kandi Member

    Joined:
    18 Nov 2009
    Messages:
    344
    Likes Received:
    17
    Reputations:
    0
    А сам?

    Hash:
    Code:
    827726fa416a20fca19381b33
    Отсекаеться:

    Code:
    [COLOR=Red]8277[/COLOR][COLOR=Lime]26fa416a20fca[/COLOR][COLOR=Red]193[/COLOR][COLOR=Lime]81b33[/COLOR]
    DecodeHash:
    Code:
    [COLOR=Yellow]acf02a614af6233b18[/COLOR]
    P.S. вглядывайся и размышляй...
     
    2 people like this.
  8. Catbert

    Catbert Banned

    Joined:
    29 Jun 2010
    Messages:
    80
    Likes Received:
    27
    Reputations:
    10
    Что-нибудь типа
    Code:
    string decode(string text)
    {
    	int len = text.Length;
    	char[] tmp = (text.Substring(len - 5) + text.Substring(4, len - 12)).ToCharArray();
    	Array.Reverse(tmp);
    	return new string(tmp);
    }
    
     
  9. RedFern.89

    RedFern.89 Member

    Joined:
    20 Jan 2010
    Messages:
    575
    Likes Received:
    48
    Reputations:
    0
    kandi, ты обсалютно прав. Я так и решил эту задачу))
     
  10. Kandi

    Kandi Member

    Joined:
    18 Nov 2009
    Messages:
    344
    Likes Received:
    17
    Reputations:
    0
    Я всматривался в черно-белый текст :D
    и потом нашёл решение данной проблемы, т.к. не алё в JavaScript :(
     
  11. RedFern.89

    RedFern.89 Member

    Joined:
    20 Jan 2010
    Messages:
    575
    Likes Received:
    48
    Reputations:
    0
    kandi, а я сначала пытался вникнуть в яваскрипт)))
     
  12. Alexus

    Alexus Elder - Старейшина

    Joined:
    5 Oct 2006
    Messages:
    9
    Likes Received:
    17
    Reputations:
    -2
    Если кому будет нужно:
    Perl

    Code:
    sub DecodeHash {
    	my @temp = split('', $_[0]);
    	my @array = @temp;
    	my @first_part=splice @array, 4, 13;
    	my @second_part=splice @temp, 20, 5;
    	my $string=join('',reverse(@first_part),reverse(@second_part));
    	return $string;
    }