Ver Mensaje Individual
  #4 (permalink)  
Antiguo 19/10/2012, 17:22
Avatar de drako_darpan
drako_darpan
 
Fecha de Ingreso: octubre-2008
Ubicación: Sinaloa
Mensajes: 617
Antigüedad: 15 años, 7 meses
Puntos: 58
Respuesta: Generar keys aleatorias

Hola que tal, bueno mira yo utilizo esto en C#, con el tengo un generador de claves :

Código C#:
Ver original
  1. txbClave.Text = " ";
  2.            
  3. string _allowedChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  4. Byte[] randomBytes = new byte[8]; // Yo pongo 8, pero tu puedes poner el tamaño que desees.
  5. char[] chars = new char[8];
  6. int allowedCharCount = _allowedChars.Length;
  7.            
  8. for( int i = 0; i<8; i++ )
  9. {
  10.       Random randomobj = new Random();
  11.       randomobj.NextBytes(randomBytes);
  12.       chars[i]=_allowedChars[(int)randomBytes[i]%allowedCharCount];
  13. }
  14.            
  15. txbClave.Text = new string(chars);