Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Prościutki skrypcik hashujący
_Mateo
post 17.12.2005, 16:08:58
Post #1





Grupa: Zarejestrowani
Postów: 189
Pomógł: 0
Dołączył: 4.03.2005
Skąd: Jaworzno

Ostrzeżenie: (0%)
-----


Witam!

Tak mnie coś naszło postanowienie stworzenia jakiejś banalnej funkcji hashującej. Nie wiem na ile mi to wyszło, ale działa.

Oto skrypt:

  1. <?php
  2.  
  3. function mha01 ( $string ) {
  4.  
  5. //czyszczenie ciągu z niedozwolonych znakow
  6.  
  7. $string = trim($string);
  8. $string = strip_tags($string);
  9.  
  10. $count = strlen($string);
  11.  
  12. //zamiana znakow z lancucha na liczby
  13.  
  14. $string = str_replace('A','6408', $string);
  15. $string = str_replace('a','7191', $string);
  16. $string = str_replace('B','2983', $string);
  17. $string = str_replace('b','5330', $string);
  18. $string = str_replace('C','450', $string);
  19. $string = str_replace('c','3367', $string);
  20. $string = str_replace('D','9241', $string);
  21. $string = str_replace('d','8137', $string);
  22. $string = str_replace('E','4472', $string);
  23. $string = str_replace('e','7413', $string);
  24. $string = str_replace('F','3449', $string);
  25. $string = str_replace('f','7408', $string);
  26. $string = str_replace('G','3163', $string);
  27. $string = str_replace('g','269', $string);
  28. $string = str_replace('H','7793', $string);
  29. $string = str_replace('h','1582', $string);
  30. $string = str_replace('I','6208', $string);
  31. $string = str_replace('i','7870', $string);
  32. $string = str_replace('J','9462', $string);
  33. $string = str_replace('j','4095', $string);
  34. $string = str_replace('K','8297', $string);
  35. $string = str_replace('k','1155', $string);
  36. $string = str_replace('L','643', $string);
  37. $string = str_replace('l','3386', $string);
  38. $string = str_replace('M','9116', $string);
  39. $string = str_replace('m','6061', $string);
  40. $string = str_replace('N','8522', $string);
  41. $string = str_replace('n','2891', $string);
  42. $string = str_replace('O','3353', $string);
  43. $string = str_replace('o','3526', $string);
  44. $string = str_replace('P','5289', $string);
  45. $string = str_replace('p','1049', $string);
  46. $string = str_replace('Q','696', $string);
  47. $string = str_replace('q','9486', $string);
  48. $string = str_replace('R','8129', $string);
  49. $string = str_replace('r','1297', $string);
  50. $string = str_replace('S','5831', $string);
  51. $string = str_replace('s','4880', $string);
  52. $string = str_replace('T','9231', $string);
  53. $string = str_replace('t','2072', $string);
  54. $string = str_replace('U','8447', $string);
  55. $string = str_replace('u','5646', $string);
  56. $string = str_replace('V','5783', $string);
  57. $string = str_replace('v','6812', $string);
  58. $string = str_replace('W','3231', $string);
  59. $string = str_replace('w','2720', $string);
  60. $string = str_replace('X','9971', $string);
  61. $string = str_replace('x','3955', $string);
  62. $string = str_replace('Y','9870', $string);
  63. $string = str_replace('y','2040', $string);
  64. $string = str_replace('Z','8984', $string);
  65. $string = str_replace('z','6937', $string);
  66. $string = str_replace('!','5722', $string);
  67. $string = str_replace('@','5617', $string);
  68. $string = str_replace('-','2361', $string);
  69. $string = str_replace('_','1954', $string);
  70. $string = str_replace('1','2215', $string);
  71. $string = str_replace('2','5432', $string);
  72. $string = str_replace('3','4542', $string);
  73. $string = str_replace('4','9644', $string);
  74. $string = str_replace('5','5408', $string);
  75. $string = str_replace('6','4638', $string);
  76. $string = str_replace('7','0145', $string);
  77. $string = str_replace('8','6775', $string);
  78. $string = str_replace('9','2496', $string);
  79. $string = str_replace('0','9535', $string);
  80.  
  81.  
  82. for($i=1; $i<=strlen($string); $i++) {
  83. $output .= $string{$i}*$string{$i+1};
  84. }
  85. $output = round($output/$count);
  86.  
  87. //czyszczenie zmiennej $string
  88.  
  89. $string = null;
  90.  
  91. //obcięcie łańcucha do 12 znakow
  92.  
  93. if(strlen($output)>12) $output=substr($output, 0, 12);
  94.  
  95. //zwrocenie zahashowanego lancucha
  96.  
  97. $output = trim($output);
  98. $output = strip_tags($output);
  99. return $output;
  100.  
  101. }
  102.  
  103. ?>

Oceńcie, ciekaw jestem czy cos takiego może wogole obsługiwać hasła, np w jakimś prostym skrycie z administracją bez użycia znanych algorytmów hashujących.

Pozdrawiam, Mateo.


--------------------
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
nospor
post 18.12.2005, 14:23:09
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Cytat(vieri_pl @ 2005-12-18 14:10:15)
Po kiego marnowałeś czas na pisanie funkcji hashującej jak mamy md5 base64 i wiele innych ...

Jesli jeszcze raz ktos sie zapyta po co to bylo pisane skoro jest md5, posypią sie warny. Czytac caly topic do jasnej ciasnej. Juz oto pytano milion razy!

pozatym base64 jest procesem odwracalnym


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post

Posty w temacie
- _Mateo   Prościutki skrypcik hashujący   17.12.2005, 16:08:58
- - dr_bonzo   Ale po co "czyscisz $stirnga: [PHP] pobi...   17.12.2005, 16:19:18
- - _Mateo   Generalnie zakładałem, że nie można do hasła dać t...   17.12.2005, 16:21:45
- - dr_bonzo   md5 czy inne nic nie zakladaja tylko hashuja to co...   17.12.2005, 16:22:52
- - mike_mech   Spodziewałem się po kimś kto ma status Developera ...   17.12.2005, 17:23:02
- - SongoQ   CytatSpodziewałem się po kimś kto ma status Develo...   17.12.2005, 17:33:10
- - Adiasz   Wogule to po kiego brac sie za pisanie czegos co j...   17.12.2005, 23:55:26
- - SongoQ   CytatBo przeciez i tak ani to nie bedzie dzialalo ...   17.12.2005, 23:59:38
- - Vengeance   _Mateo: jeśli już... nie łatwiej jest zrobić for()...   18.12.2005, 00:14:01
- - sopel   co czytam artykul o bezpieczenstwie gdzie poruszon...   18.12.2005, 01:21:59
- - NuLL   EOT dot dev.php.pl - developerzy php.pl to grupa o...   18.12.2005, 02:30:43
- - SongoQ   Nie chce byc zlosliwy ale troche mnie to smieszy, ...   18.12.2005, 02:41:22
- - dr_bonzo   SongoQ: nie generalizuj. NuLL prosil o EOT. Bo zar...   18.12.2005, 02:52:38
- - vieri_pl   Po kiego marnowałeś czas na pisanie funkcji hashuj...   18.12.2005, 14:10:15
- - nospor   Cytat(vieri_pl @ 2005-12-18 14:10:15)Po kiego...   18.12.2005, 14:23:09
- - vieri_pl   Fakt pomyliłem się z base64, .... edytnołem i ve...   18.12.2005, 14:33:33
- - _Mateo   Wiecie co... Macie totalną racje nie wiem co mi ...   18.12.2005, 20:02:29
- - hwao   Ciekawy pomysl, ale kompletnie nie optymalny... Te...   18.12.2005, 22:32:23


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 19:07