Expermicid Posted October 12, 2012 Share Posted October 12, 2012 (edited) Funcion que genera un variable randomizada, tomando como caracteres un alfabeto definido previamente. [lenguaje=java]/* Funcion sRandom * Autor : Expermicid * Fecha : 12/10/12 * Modo de uso : sRandom(Longitud) */ private static String sRandom(int longitud) { String aux = ""; String alfabeto = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; int cant = 32; int i; for (i=1;i<=longitud;i++) { aux = aux + alfabeto.charAt((int)(Math.random()*cant)+1); } return aux; }[/lenguaje] En funcionamiento This is the hidden content, please Sign In or Sign Up Saludos Edited February 16, 2014 by Expermicid Link to comment Share on other sites More sharing options...
Recommended Posts