/*
 * 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();
        if (containsDigit(chiave)) {
            return null;
        }
        Mappatura m = new Mappatura();
        char[] res = new char[26];
        for (int i = 0; i < chiave.length(); i++) {
            res[i] = chiave.charAt(i);
        }
        m.setMappaInversa(res);
        return m;
    }

    private boolean containsDigit(String string) {
        return string.matches(".*\\d.*");
    }
}

@@ -507,49 +507,107 @@
     
-if (containsDigit(chiave)) %7B%0D%0A   
+Mappatura m = new Mappatura();%0D%0A        //m.setMappaInversa(merge(chiave, m.getMappa()));%0D%0A
         
  ret
@@ -606,27 +606,19 @@
     
- 
 return 
-null
+m
 ;%0D%0A
-    
     
@@ -628,47 +628,64 @@
     
-    Mappatura m = new Mappatura();%0D%0A   
+/*%0D%0A     private char%5B%5D merge(String key, char%5B%5D map)%7B%0D%0A
     
@@ -718,19 +718,41 @@
 ;%0D%0A     
+boolean duplicate;%0D%0A
    
+  
 for (int
@@ -767,245 +767,168 @@
 i %3C 
-chiave.length(); i++) %7B%0D%0A            res%5Bi%5D = chiave.charAt(i);%0D%0A        %7D%0D%0A        m.setMappaInversa(res);%0D%0A        return m;
+10; i++) %7B%0D%0A     duplicate = false;%0D%0A     for (int j = i; !duplicate && j %3E=0; j--) %7B%0D%0A     if(key.charAt(i) == )
 %0D%0A    
+ 
 %7D
-%0D%0A
 %0D%0A    
-private boolean containsDigit(String string) %7B%0D%0A        return string.matches(%22.*%5C%5Cd.*%22)
+ %7D%0D%0A     return null
 ;%0D%0A    
-%7D
+ %7D*/%0D%0A
 %0D%0A%7D%0D

Revert "Merge origin/master"