Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2006.09.03;
Скачать: CL | DM;

Вниз

base64_encode(pack("H*", sha1(utf8_encode($_GET[ pwd ])))))   Найти похожие ветки 

 
qazwsx ©   (2006-04-13 23:12) [0]

Как на delphi сделать вот такую вот штуку:
base64_encode(pack("H*", sha1(utf8_encode($_GET["pwd"])))))

Как я понял тут и sha1 и base64 и pack какой-то...


 
Eraser ©   (2006-04-13 23:15) [1]


> qazwsx ©   (13.04.06 23:12)

в одну сточку вряд ли получится )


 
qazwsx ©   (2006-04-13 23:24) [2]

знаю, а написать сами алгоритмы можете? Или ссылки дать?


 
Eraser ©   (2006-04-13 23:39) [3]


> qazwsx ©   (13.04.06 23:24) [2]

по  base64_encode вроде в Indy есть соотв. компонент.
по sha1 - есть полно готовых решений, начиная с CryptoAPI и заканчивая компонентами LockBox.
по utf8_encode - есть стандартная ф-я UTF8Encode.
насчёт pack - не вкурсе что это означает в контексте вашего примера.

>  а написать сами алгоритмы можете?

нет.


 
qazwsx ©   (2006-04-14 00:12) [4]

то что я привел в пример, написанно на php мне нужно тоже самое написать на pascal"e


 
qazwsx ©   (2006-04-14 00:13) [5]

и еще sha1 у мну есть уже, но он каждый раз выдает разные "стринги" а php выдает всегда одинаковые...


 
sicilla ©   (2006-04-15 15:56) [6]

function EncodeBase64(const inStr: string): string;

 function Encode_Byte(b: Byte): char;
 const
   Base64Code: string[64] =
     "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 begin
   Result := Base64Code[(b and $3F)+1];
 end;

var
 i: Integer;
begin
 i := 1;
 Result := "";
 while i < =Length(InStr) do
 begin
   Result := Result + Encode_Byte(Byte(inStr[i]) shr 2);
   Result := Result + Encode_Byte((Byte(inStr[i]) shl 4) or (Byte(inStr[i+1]) shr 4));
   if i+1 < =Length(inStr) then
     Result := Result + Encode_Byte((Byte(inStr[i+1]) shl 2) or (Byte(inStr[i+2]) shr 6))
   else
     Result := Result + "=";
   if i+2 < =Length(inStr) then
     Result := Result + Encode_Byte(Byte(inStr[i+2]))
   else
     Result := Result + "=";
   Inc(i, 3);
 end;
end;

// Base64 decoding
function DecodeBase64(const CinLine: string): string;
const
 RESULT_ERROR = -2;
var
 inLineIndex: Integer;
 c: Char;
 x: SmallInt;
 c4: Word;
 StoredC4: array[0..3] of SmallInt;
 InLineLength: Integer;
begin
 Result := "";
 inLineIndex := 1;
 c4 := 0;
 InLineLength := Length(CinLine);

 while inLineIndex < =InLineLength do
 begin
   while (inLineIndex < =InLineLength) and (c4 < 4) do
   begin
     c := CinLine[inLineIndex];
     case c of
       "+"     : x := 62;
       "/"     : x := 63;
       "0".."9": x := Ord(c) - (Ord("0")-52);
       "="     : x := -1;
       "A".."Z": x := Ord(c) - Ord("A");
       "a".."z": x := Ord(c) - (Ord("a")-26);
     else
       x := RESULT_ERROR;
     end;
     if x < > RESULT_ERROR then
     begin
       StoredC4[c4] := x;
       Inc(c4);
     end;
     Inc(inLineIndex);
   end;

   if c4 = 4 then
   begin
     c4 := 0;
     Result := Result + Char((StoredC4[0] shl 2) or (StoredC4[1] shr 4));
     if StoredC4[2] = -1 then Exit;
     Result := Result + Char((StoredC4[1] shl 4) or (StoredC4[2] shr 2));
     if StoredC4[3] = -1 then Exit;
     Result := Result + Char((StoredC4[2] shl 6) or (StoredC4[3]));
   end;
 end;
end;


Чего тут гадать?



Страницы: 1 вся ветка

Текущий архив: 2006.09.03;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.04 c
15-1155408021
Firefly
2006-08-12 22:40
2006.09.03
Дипломная работа


4-1147205976
444ert666
2006-05-10 00:19
2006.09.03
TRAY-help!!!!!!!!!!!!!!!!


15-1154798853
lookin
2006-08-05 21:27
2006.09.03
Обращение к магнитогорцам


15-1154465545
Gero
2006-08-02 00:52
2006.09.03
Земля сегодня


2-1155225004
Fu
2006-08-10 19:50
2006.09.03
Функция





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский