Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> szyfrowanie RC4, a klucz mieszany przez sha1
Cathan
post
Post #1





Grupa: Zarejestrowani
Postów: 24
Pomógł: 0
Dołączył: 21.04.2005

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


Witam
Mam pytanie.
Musze zaszyfrowac string za pomoca RC4 - i nie bylo by tak zle, gdyby nie fakt - iz klucz jest szyfrowany sha1. php zwraca problem z dlugośćią stringa - sha daje 40 obslugiwany jest 32

a na php.net jestraczej srednia rada
Cytat
Avoid using string representations hashes - md5() or sha1() - because hex encoding uses a set of only 16 characters [0-9a-f], which is equivalent to 4 bits, and thus halve the strength of your encryption: 4 x 32 = 128-bit.


a koniecznie klucz musi byc szyfrowany przez sha1

Jak rozwiazać taki problem??
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
hwao
post
Post #2


Developer


Grupa: Moderatorzy
Postów: 2 844
Pomógł: 20
Dołączył: 25.11.2003
Skąd: Olkusz




Stary temat ale trafia się na niego przez google przy specificznym problemie, więc daje rozwiązanie:

Korzystając z:
http://pear.php.net/package/Crypt_RC42/doc...ptRC42.php.html

  1. <?php
  2.  
  3. $key = "klucz";
  4.  
  5. $message = file_get_contents( 'input.txt' );
  6.  
  7. include '/Crypt/RC42.php';
  8. $rc4 = new Crypt_RC42();
  9.  
  10. $key = ( sha1( $key, true ) );
  11.  
  12. $rc4->key($key);
  13.  
  14. $message = $rc4->encrypt($message);
  15. file_put_contents( 'output.txt', $message );
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 27.12.2025 - 07:13