/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cryptohelper.data;

import cryptohelper.interfaces.CalcolatoreMappatura;

/**
 *
 * @author Sasha Alexandru Podgoreanu
 */
public class CalcolatoreParolaChiave extends CalcolatoreMappatura {

    @Override
    public Mappatura calcola(String chiave) {
        chiave = chiave.toLowerCase();
        Mappatura m = new Mappatura();
        //m.setMappaInversa(merge(chiave, m.getMappa()));
        return m;
    }
    /*
     private char[] merge(String key, char[] map){
     char[] res = new char[26];
     boolean duplicate;
     for (int i = 0; i < 10; i++) {
     duplicate = false;
     for (int j = i; !duplicate && j >=0; j--) {
     if(key.charAt(i) == )
     }
     }
     return null;
     }*/

}

@@ -547,10 +547,8 @@
     
-//
 m.se
@@ -622,17 +622,10 @@
  %7D%0D%0A
-    /*
 %0D%0A
- 
     
@@ -668,24 +668,25 @@
 r%5B%5D map)
+ 
 %7B%0D%0A     
 char%5B%5D r
@@ -677,16 +677,19 @@
 %7B%0D%0A     
+   
 char%5B%5D r
@@ -708,16 +708,39 @@
 r%5B26%5D;%0D%0A
+        int k = 0;%0D%0A   
      boo
@@ -752,24 +752,27 @@
 duplicate;%0D%0A
+   
      for (in
@@ -792,24 +792,31 @@
 10; i++) %7B%0D%0A
+       
      duplica
@@ -829,24 +829,31 @@
 alse;%0D%0A     
+   
+    
 for (int j =
@@ -854,16 +854,20 @@
 nt j = i
+ - 1
 ; !dupli
@@ -878,16 +878,17 @@
  && j %3E=
+ 
 0; j--) 
@@ -894,15 +894,27 @@
  %7B%0D%0A
+           
      if
+ 
 (key
@@ -931,19 +931,84 @@
  == 
-)%0D%0A
+key.charAt(j)) %7B%0D%0A                    duplicate = true;%0D%0A           
      %7D%0D%0A
     
@@ -999,24 +999,31 @@
          %7D%0D%0A
+       
      %7D%0D%0A    
@@ -1027,30 +1027,498 @@
     
-return null;%0D%0A     %7D*/
+       if (!duplicate && k %3C res.length) %7B%0D%0A                res%5Bk%5D = key.charAt(i);%0D%0A            %7D%0D%0A        %7D%0D%0A        for (int i = 0; i %3C map.length; i++) %7B%0D%0A            duplicate = false;%0D%0A            for (int j = 0; j %3C k; j++) %7B%0D%0A                if (map%5Bi%5D == res%5Bj%5D) %7B%0D%0A                    duplicate = true;%0D%0A                %7D%0D%0A            %7D%0D%0A            if (!duplicate && k %3C res.length) %7B%0D%0A                res%5Bk%5D = key.charAt(i);%0D%0A            %7D%0D%0A        %7D%0D%0A        return res;%0D%0A    %7D
 %0D%0A%0D%0A

Revert "Merge origin/master"