Foros del Web » Programando para Internet » PHP »

Encriptar y desencriptar

Estas en el tema de Encriptar y desencriptar en el foro de PHP en Foros del Web. hola a todos tengo dificultades para utilizar una librería PHP para encriptar y una biblioteca de rubí on rails para descifrar o alguien tiene alguna ...
  #1 (permalink)  
Antiguo 30/06/2011, 12:41
 
Fecha de Ingreso: septiembre-2008
Mensajes: 192
Antigüedad: 15 años, 7 meses
Puntos: 1
Encriptar y desencriptar

hola a todos tengo dificultades para utilizar una librería PHP para encriptar y una biblioteca de rubí on rails para descifrar o alguien tiene alguna otra mejor forma de realizarlo.
RUBI ON RAILS
Código Rubi on rails:
Ver original
  1. require 'openssl'
  2.     file_path_key = "data.bin1"
  3.    
  4.     file_path_key_ = "wrapped.bin1"
  5. private_key_file = "private.key";
  6.   wrapped = File.read(file_path_key_)
  7.   cipher_text = File.read(file_path_key)
  8.  
  9.   privkey = OpenSSL::PKey::RSA.new(File.read(private_key_file))
  10.  #p privkey
  11.   key = privkey.private_decrypt(wrapped)
  12. #p  privkey.private_decrypt(Base64.decode64(File.read(file_path_key_)))
  13.   #p key
  14.     cipher = OpenSSL::Cipher.new('rc4')
  15.   cipher.decrypt
  16.  
  17.  
  18.   cipher.key = key
  19.  
  20. p cipher.update(cipher_text)

Código PHP:
Ver original
  1. $pubkey = openssl_pkey_get_public(file_get_contents('public.key'));
  2.  
  3. $message = 'hello,world';
  4. $cipher_text = "hi";
  5.  
  6. $keys = NULL;
  7. openssl_seal($message, $cipher_text, $keys, array($pubkey));
  8. echo sizeof($keys);
  9. $file = fopen('wrapped.bin1', 'wb');
  10. fwrite($file, $keys[0]);
  11. fclose($file);
  12.  
  13. $file = fopen('data.bin1', 'wb');
  14. fwrite($file, $cipher_text);
  15. fclose($file);
  #2 (permalink)  
Antiguo 01/07/2011, 00:22
Avatar de repara2  
Fecha de Ingreso: septiembre-2010
Ubicación: München
Mensajes: 2.445
Antigüedad: 13 años, 7 meses
Puntos: 331
Respuesta: Encriptar y desencriptar

http://www.phpclasses.org/package/44...etrically.html
__________________
Fere libenter homines, id quod volunt, credunt.

Etiquetas: desencriptar, encriptar
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:51.