elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: (TUTORIAL) Aprende a emular Sentinel Dongle By Yapis


  Mostrar Mensajes
Páginas: 1 [2] 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ... 63
11  Programación / Java / contribucion una red neuronal con algebra lineal en: 10 Agosto 2022, 19:07 pm
hola este es un pequeño ejemplo de como se hace una red neuronal en java


Código
  1.  
  2. package matrix;
  3.  
  4. import java.util.function.BiFunction;
  5. import java.util.function.Function;
  6.  
  7. public class Main {
  8. public static void main(String[] args) {
  9. double[][] training_set_inputs = new double[][] { { 0, 0, 1 }, { 1, 1, 1 }, { 1, 0, 1 }, { 0, 1, 0 } };
  10. double[][] training_set_outputs = t(new double[][] { { 0, 1, 1, 0 } });
  11. double[][] synaptic_weights = new double[][] { { -0.5 }, { -0.5}, { -0.5} };
  12.  
  13. for (int c = 0; c < 700_000; c++) {
  14. double[][] output = div(1, sum(1, exp(neg(dot(training_set_inputs, synaptic_weights)))));
  15. double[][] error = subtract(training_set_outputs,output);
  16. double[][] sigder = mul(output,min(1,output));
  17. double[][] adjustment = dot(t( training_set_inputs ),mul(error, sigder));
  18. synaptic_weights= sum(synaptic_weights,adjustment);
  19. }
  20.  
  21. print(div(1, sum(1, exp(neg(dot( new double[][] { {1 , 0 , 0 } }, synaptic_weights))))));
  22. }
  23.  
  24.  
  25. private static void println() {
  26. System.out.println();
  27. }
  28.  
  29. static double[][] dot(double[][] a, double[][] b) {
  30. double[][] result = zero(a.length, b[0].length);
  31.  
  32. for (int i = 0; i < a.length; i++) {
  33. for (int j = 0; j < a[0].length; j++) {
  34. for (int k = 0; k < b[0].length; k++) {
  35. result[i][k] += a[i][j] * b[j][k];
  36. }
  37. }
  38. }
  39.  
  40. return result;
  41. }
  42.  
  43. static double[][] operate(double[][] a, double[][] b, BiFunction<Double, Double, Double> call) {
  44. double[][] result = zero(a.length, b[0].length);
  45.  
  46. for (int i = 0; i < a.length; i++) {
  47. for (int j = 0; j < a[0].length; j++) {
  48. result[i][j] = call.apply(a[i][j], b[i][j]);
  49.  
  50. }
  51. }
  52.  
  53. return result;
  54. }
  55.  
  56. static double[][] operate(double a, double[][] b, BiFunction<Double, Double, Double> call) {
  57. double[][] result = zero(b.length, b[0].length);
  58.  
  59. for (int i = 0; i < b.length; i++) {
  60. for (int j = 0; j < b[0].length; j++) {
  61. result[i][j] = call.apply(a, b[i][j]);
  62.  
  63. }
  64. }
  65.  
  66. return result;
  67. }
  68.  
  69. static double[][] operate(double[][] a, Function<Double, Double> call) {
  70. double[][] result = zero(a.length, a[0].length);
  71.  
  72. for (int i = 0; i < a.length; i++) {
  73. for (int j = 0; j < a[0].length; j++) {
  74. result[i][j] = call.apply(a[i][j]);
  75.  
  76. }
  77. }
  78.  
  79. return result;
  80. }
  81.  
  82. static double[][] div(double a, double[][] b) {
  83.  
  84. return operate(a, b, (p, q) -> p / q);
  85. }
  86.  
  87. static double[][] sum(double a, double[][] b) {
  88.  
  89. return operate(a, b, (p, q) -> p + q);
  90. }
  91.  
  92. static double[][] min(double a, double[][] b) {
  93.  
  94. return  operate(a, b, (p, q) -> p - q);
  95. }
  96.  
  97.  
  98. static double[][] div(double[][] a, double[][] b) {
  99.  
  100. return operate(a, b, (p, q) -> p / q);
  101. }
  102.  
  103. static double[][] mul(double[][] a, double[][] b) {
  104.  
  105. return operate(a, b, (p, q) -> p * q);
  106. }
  107.  
  108. static double[][] mul(double a, double[][] b) {
  109.  
  110. return operate(a, b, (p, q) -> p * q);
  111. }
  112.  
  113. static double[][] sum(double[][] a, double[][] b) {
  114.  
  115. return operate(a, b, (p, q) -> p + q);
  116. }
  117.  
  118. static double[][] subtract(double[][] a, double[][] b) {
  119.  
  120. return operate(a, b, (p, q) -> p - q);
  121. }
  122.  
  123. static double[][] exp(double[][] a) {
  124. return operate(a, (p) -> Math.exp(p));
  125. }
  126.  
  127. static double[][] neg(double[][] a) {
  128. return mul(-1, a);
  129. }
  130.  
  131. private static double[][] zero(int rows, int cols) {
  132. return new double[rows][cols];
  133. }
  134.  
  135.  
  136.  
  137.  
  138. static double[][] expand(double[][] a, double value) {
  139. int firstDimension = a.length;
  140. int secondDimensio = a[0].length;
  141. double [][]result = zero(firstDimension, secondDimensio);
  142. for (int i = 0; i < firstDimension; i++) {
  143. for (int j = 0; j < secondDimensio; j++) {
  144.  
  145. result[i][j] = value;
  146. }
  147.  
  148. }
  149. return result;
  150. }
  151.  
  152. static double[][] t(double[][] a) {
  153. int firstDimension = a.length;
  154. int secondDimensio = a[0].length;
  155. double[][] result = new double[secondDimensio][firstDimension];
  156. for (int i = 0; i < firstDimension; i++) {
  157. for (int j = 0; j < secondDimensio; j++) {
  158.  
  159. result[j][i] = a[i][j];
  160. }
  161.  
  162. }
  163. return result;
  164. }
  165.  
  166. static void print(double[][] a) {
  167. int firstDimension = a.length;
  168. int secondDimensio = a[0].length;
  169.  
  170. for (int i = 0; i < firstDimension; i++) {
  171. for (int j = 0; j < secondDimensio; j++) {
  172. String coma = secondDimensio - 1 == j ? "" : " , ";
  173. System.out.print(a[i][j] + coma);
  174. }
  175. println();
  176. }
  177. }
  178. }
  179.  
  180.  
  181.  
12  Programación / Java / Re: Ayudaaaaa. Exception in thread "main" java.lang.NullPointerException en java en: 16 Junio 2022, 00:05 am
falta la clase cliente no se puede ayuda si no esta completa
13  Programación / Java / Re: sapito169 en: 16 Mayo 2022, 00:39 am
El lenguaje no tiene nada q ver
Todo lo q puedes hacer en un lenguaje lo puedes hacer en otro
14  Programación / Java / Re: Por que NB me arroja este error? en: 15 Abril 2022, 06:36 am
cambiate a eclipse nb hace rato dejo de tener buen soporte
15  Programación / Java / Re: Sockets fuera de LAN. en: 11 Abril 2022, 16:51 pm
 ::) ::) ::)

un tutorial de como hacer hacer tunel con ngrock

https://www.youtube.com/watch?v=omejBwczrlE

16  Programación / Java / Re: Sockets fuera de LAN. en: 10 Abril 2022, 06:35 am
ngrock es tu amigo

 :: ::)

Pero replantear cambiar sckets por hhtp lo hace más fácil para q
 el Sr heroku y speing boot te ayuden
17  Programación / Java / Ejemplo de Token Digital en: 5 Abril 2022, 07:59 am
hola a qui una pequeño ejemplo de token digital

todo en memoria esta lejos de estar completo

y un parde fotitos



 
Código
  1. package otpserver.simple;
  2.  
  3.  
  4. import java.awt.event.ActionEvent;
  5. import java.security.MessageDigest;
  6. import java.time.LocalDateTime;
  7. import java.time.ZoneId;
  8. import java.util.Base64;
  9. import java.util.Random;
  10.  
  11. import javax.xml.bind.DatatypeConverter;
  12.  
  13. import javafx.application.Application;
  14. import javafx.application.Platform;
  15. import javafx.scene.Scene;
  16. import javafx.scene.layout.*;
  17. import javafx.scene.text.Text;
  18. import javafx.scene.control.*;
  19.  
  20. import javafx.stage.Stage;
  21.  
  22. public class CounterApp extends Application {
  23.  
  24.  
  25.    private final Text text = new Text();
  26.    private final Text codigoSecreto = new Text();
  27.    private final Button boton = new Button("muestra secreto");
  28.    private String secreto= "";
  29.    private boolean muestra = false;
  30.    private void incrementCount() {
  31.         try {
  32.  
  33.         long a = System.currentTimeMillis()/(1000*60);
  34.         MessageDigest instance = MessageDigest.getInstance("MD5");
  35. instance.update((secreto +a).getBytes());
  36.         byte[] digest = instance.digest();
  37.         String token = DatatypeConverter.printHexBinary(digest).toUpperCase();
  38.     text.setText(  LocalDateTime.now() +"\n"+ token.substring(0, 5) );
  39. } catch (Exception e) {
  40. throw new RuntimeException(e);
  41. }
  42.  
  43.    }
  44.  
  45.    @Override
  46.    public void start(Stage primaryStage) {
  47.  
  48.     Random random = new Random();
  49.  
  50.     for (int c = 0;c<4;c++) {
  51.     secreto+=random.nextInt(9);
  52.     }
  53.  
  54.  
  55.        VBox root = new VBox();
  56.  
  57.        root.getChildren().add(boton);
  58.        root.getChildren().add(codigoSecreto);
  59.  
  60.        root.getChildren().add(text);
  61.  
  62.  
  63.        Scene scene = new Scene(root, 200, 200);
  64.  
  65.        // longrunning operation runs on different thread
  66.        Thread thread = new Thread(new Runnable() {
  67.  
  68.            @Override
  69.            public void run() {
  70.                Runnable updater = new Runnable() {
  71.  
  72.                    @Override
  73.                    public void run() {
  74.                        incrementCount();
  75.                    }
  76.                };
  77.  
  78.                while (true) {
  79.                    try {
  80.                        Thread.sleep(1000);
  81.                    } catch (InterruptedException ex) {
  82.                    }
  83.  
  84.                    // UI update is run on the Application thread
  85.                    Platform.runLater(updater);
  86.                }
  87.            }
  88.  
  89.        });
  90.        // don't let thread prevent JVM shutdown
  91.        thread.setDaemon(true);
  92.        thread.start();
  93.  
  94.        boton.setOnAction(p->{
  95.         muestra=!muestra;
  96.         if(muestra)
  97.         codigoSecreto.setText(secreto);
  98.         else
  99.         codigoSecreto.setText("*****");
  100.        });
  101.        primaryStage.setTitle("Token Digital");
  102.        primaryStage.setScene(scene);
  103.        primaryStage.show();
  104.    }
  105.  
  106.    public static void main(String[] args) {
  107.        launch(args);
  108.    }
  109.  
  110. }
  111.  


Código
  1. package otpserver.simple;
  2.  
  3. import java.awt.event.ActionEvent;
  4. import java.security.MessageDigest;
  5. import java.security.NoSuchAlgorithmException;
  6. import java.time.LocalDateTime;
  7. import java.time.ZoneId;
  8. import java.util.Base64;
  9. import java.util.Optional;
  10. import java.util.Random;
  11.  
  12. import javax.swing.JOptionPane;
  13. import javax.xml.bind.DatatypeConverter;
  14.  
  15. import javafx.application.Application;
  16. import javafx.application.Platform;
  17. import javafx.scene.Scene;
  18. import javafx.scene.layout.*;
  19. import javafx.scene.text.Text;
  20. import javafx.scene.control.*;
  21.  
  22. import javafx.stage.Stage;
  23.  
  24.  
  25. public class Login extends Application {
  26.  
  27. private final TextField usuario = new TextField();
  28. private final PasswordField clave = new PasswordField();
  29. private final TextField token = new TextField();
  30.  
  31. private final Button boton = new Button("login");
  32.  
  33. private boolean tieneToken = false;
  34. private String secretotoken = "";
  35.  
  36. @Override
  37. public void start(Stage primaryStage) {
  38.  
  39. usuario.setPromptText("usuario");
  40. token.setPromptText("token");
  41. token.setVisible(false);
  42. VBox root = new VBox();
  43.  
  44. root.getChildren().add(usuario);
  45.  
  46. root.getChildren().add(clave);
  47.  
  48. root.getChildren().add(token);
  49.  
  50. root.getChildren().add(boton);
  51.  
  52. Scene scene = new Scene(root, 200, 200);
  53.  
  54. // longrunning operation runs on different thread
  55.  
  56. boton.setOnAction(p -> {
  57.  
  58. if (usuario.getText().equals("admin") && clave.getText().equals("admin") && !tieneToken) {
  59. System.out.println("xd");
  60. TextInputDialog dialog = new TextInputDialog();
  61. dialog.setTitle("parear");
  62. dialog.setHeaderText("parear");
  63.  
  64. // Traditional way to get the response value.
  65. Optional<String> result = dialog.showAndWait();
  66. if (result.isPresent()) {
  67. tieneToken = true;
  68. token.setVisible(tieneToken);
  69.  
  70. }
  71.  
  72. // The Java 8 way to get the response value (with lambda expression).
  73. result.ifPresent(name -> {
  74. secretotoken=name;
  75. });
  76. }
  77.  
  78. if (usuario.getText().equals("admin") && clave.getText().equals("admin") && tieneToken) {
  79. try {
  80.  
  81.         long a = System.currentTimeMillis()/(1000*60);
  82.         MessageDigest instance = MessageDigest.getInstance("MD5");
  83. instance.update((secretotoken +a).getBytes());
  84.         byte[] digest = instance.digest();
  85.         String tokenProvar = DatatypeConverter.printHexBinary(digest).toUpperCase();
  86.         System.out.println("tokenProvar "+tokenProvar);
  87.         if(token.getText().equals(tokenProvar.substring(0,5))) {
  88.         JOptionPane.showMessageDialog(null, "exito");
  89.         }else {
  90.         JOptionPane.showMessageDialog(null, "eres falla");
  91.         }
  92. } catch (Exception e) {
  93. throw new RuntimeException(e);
  94. }
  95. }
  96.  
  97. });
  98. primaryStage.setTitle("Login");
  99. primaryStage.setScene(scene);
  100. primaryStage.show();
  101. }
  102.  
  103. public static void main(String[] args) {
  104. launch(args);
  105. }
  106.  
  107. }
  108.  













MOD: Enlaces a imágenes corregidos
Mod: Titulos descriptivos.
18  Programación / Java / Re: se pueden crear clases independientes? en: 1 Abril 2022, 23:42 pm
 :xD :xD :xD

solo tienes que dar click derecho sobre la clase luego le das correr

y si puedes tener varias clases dentro del mismo proyecto cada una con main

recuerda que la forma mas facil
es que cada clase tentenga el mismo nombre que el archivo y un archivo solo tenga una clase
19  Programación / Java / Re: ¨No local JVMs detected ¨ en: 28 Febrero 2022, 00:13 am
no entender

la foto que muestras es Mision Control

esa herramienta es para monitorear una aplicacion que ya este funcionando

te muestra el mensaje de error por que primero tienes que crear una aplicacion luego la herramienta puede verla
20  Programación / Java / Re: Problema al momento de crear metodo static en: 25 Febrero 2022, 15:37 pm
Vale! gracias
¿Me podrias decir porque no se recomienda?
Es que a mi me estan enseñando de esa forma

tu profesor es noob y no sabe programar no le creeas nada pero no le digas lo que te dije que el cojudo crea lo que quiere

yo soy bien chingon y he hecho varios programas complejos todos funcionando (que es lo unico que cuenta) y he estado participando y explicando a gente grande (no como tu profe) la mejor manera de diseñar software
Páginas: 1 [2] 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ... 63
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines