Model obfuscator refactored to use proper random seed

	Obfuscator uses base36 string to represent a BigInteger seed
	Builders updated to handle BigInteger seeds
	Deprecate string seed in StringObfuscator
	UML obfuscator uses salt by default
diff --git a/plugins/org.eclipse.viatra.modelobfuscator.application/src/org/eclipse/viatra/modelobfuscator/application/common/ModelObfuscatorHeadless.java b/plugins/org.eclipse.viatra.modelobfuscator.application/src/org/eclipse/viatra/modelobfuscator/application/common/ModelObfuscatorHeadless.java
index b18cbca..cc718d0 100644
--- a/plugins/org.eclipse.viatra.modelobfuscator.application/src/org/eclipse/viatra/modelobfuscator/application/common/ModelObfuscatorHeadless.java
+++ b/plugins/org.eclipse.viatra.modelobfuscator.application/src/org/eclipse/viatra/modelobfuscator/application/common/ModelObfuscatorHeadless.java
@@ -17,6 +17,7 @@
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.math.BigInteger;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -36,8 +37,8 @@
 import org.eclipse.emf.ecore.xmi.XMLResource;
 import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;
 import org.eclipse.equinox.app.IApplication;
+import org.eclipse.viatra.modelobfuscator.emf.simple.AbstractModelObfuscator;
 import org.eclipse.viatra.modelobfuscator.emf.simple.EMFModelObfuscatorBuilder;
-import org.eclipse.viatra.modelobfuscator.emf.simple.SimpleEMFModelObfuscator;
 import org.eclipse.viatra.modelobfuscator.xml.XMLModelObfuscator;
 import org.eclipse.viatra.modelobfuscator.xml.XMLModelObfuscatorBuilder;
 import org.eclipse.viatra.modelobfuscator.xml.XMLSchemaConfiguration;
@@ -172,7 +173,7 @@
         obfuscatorBuilder.setInput(resourceSet);
         
         if(seed != null) {
-            obfuscatorBuilder.setSeed(seed);
+            obfuscatorBuilder.setSeed(new BigInteger(seed, 36));
         }
         System.out.println("Obfuscating using seed: " + obfuscatorBuilder.getSeed());
         
@@ -265,7 +266,7 @@
      * @param obfuscatorBuilder
      */
     private void performObfuscation(EMFModelObfuscatorBuilder obfuscatorBuilder) {
-        SimpleEMFModelObfuscator obfuscator = obfuscatorBuilder.build();
+        AbstractModelObfuscator obfuscator = obfuscatorBuilder.build();
         System.out.println("Obfuscating EMF resource set");
         Stopwatch stopwatch = Stopwatch.createStarted();
         obfuscator.obfuscate();
@@ -349,7 +350,7 @@
         XMLModelObfuscatorBuilder obfuscatorBuilder = XMLModelObfuscatorBuilder.create().setSchemaConfiguration(schemaConfiguration);
         
         if(seed != null) {
-            obfuscatorBuilder.setSeed(seed);
+            obfuscatorBuilder.setSeed(new BigInteger(seed, 36));
         }
         System.out.println("Obfuscating using seed: " + obfuscatorBuilder.getSeed());
         
@@ -514,7 +515,7 @@
                 + "<call> -c <configurationFilePath> [-s <seed>] [-salt <salt>]\n"
                 + "  -c       : Required, the configuration that describes what to obfuscate.\n"
                 + "  --config : Same as -c.\n"
-                + "  -s       : Optional, the seed used for the obfuscation.\n"
+                + "  -s       : Optional, the seed used for the obfuscation. Must be base 36 number as string\n"
                 + "  --seed   : Same as -s.\n"
                 + "  --salt   : Optional, the salt used for the obfuscation.");
     }
diff --git a/plugins/org.eclipse.viatra.modelobfuscator.runtime.uml/src/org/eclipse/viatra/modelobfuscator/emf/uml/SimpleUMLProfileReplacer.xtend b/plugins/org.eclipse.viatra.modelobfuscator.runtime.uml/src/org/eclipse/viatra/modelobfuscator/emf/uml/SimpleUMLProfileReplacer.xtend
index 9a77728..e59a680 100644
--- a/plugins/org.eclipse.viatra.modelobfuscator.runtime.uml/src/org/eclipse/viatra/modelobfuscator/emf/uml/SimpleUMLProfileReplacer.xtend
+++ b/plugins/org.eclipse.viatra.modelobfuscator.runtime.uml/src/org/eclipse/viatra/modelobfuscator/emf/uml/SimpleUMLProfileReplacer.xtend
@@ -25,7 +25,6 @@
 	protected Model inputModel
 	protected Profile oldProfile
 	protected Profile newProfile
-	protected String seedString
 	protected String saltString = ""
 	protected extension StringObfuscator stringObfuscator
 	private boolean toOriginal = false
@@ -37,7 +36,6 @@
 	def replace(boolean toOriginal) {
 		Preconditions.checkState(inputModel != null, "Input resource set must not be null")
 		Preconditions.checkState(newProfile != null, "New profile must not be null")
-		Preconditions.checkState(seedString != null, "Seed string must not be null")
 		Preconditions.checkState(stringObfuscator != null, "String obfuscator must not be null")
 		
 		val prevDir = this.toOriginal
diff --git a/plugins/org.eclipse.viatra.modelobfuscator.runtime.uml/src/org/eclipse/viatra/modelobfuscator/emf/uml/UMLObfuscatorBuilder.xtend b/plugins/org.eclipse.viatra.modelobfuscator.runtime.uml/src/org/eclipse/viatra/modelobfuscator/emf/uml/UMLObfuscatorBuilder.xtend
index ce26b18..48fb89c 100644
--- a/plugins/org.eclipse.viatra.modelobfuscator.runtime.uml/src/org/eclipse/viatra/modelobfuscator/emf/uml/UMLObfuscatorBuilder.xtend
+++ b/plugins/org.eclipse.viatra.modelobfuscator.runtime.uml/src/org/eclipse/viatra/modelobfuscator/emf/uml/UMLObfuscatorBuilder.xtend
@@ -10,96 +10,29 @@
  *******************************************************************************/
 package org.eclipse.viatra.modelobfuscator.emf.uml
 
-import com.google.common.base.Preconditions
-import java.util.Map
-import org.eclipse.viatra.modelobfuscator.emf.simple.ResourceFilter
-import org.eclipse.emf.ecore.resource.ResourceSet
+import org.eclipse.viatra.modelobfuscator.emf.simple.EMFModelObfuscatorBuilder
 import org.eclipse.viatra.modelobfuscator.util.ObfuscatorUtil
-import org.eclipse.viatra.modelobfuscator.util.StringObfuscator
 
-class UMLObfuscatorBuilder {
+class UMLObfuscatorBuilder extends EMFModelObfuscatorBuilder {
 
-  private ResourceSet inputRS
-  private ResourceFilter filter
-  private String saltString = ""
-  private String seedString = ObfuscatorUtil.generateHexSeed(32)
-  private Map<String,String> obfuscationMap = null
-
-  /**
-   * Hiding constructor of builder
-   */
-  protected new() {}
-
-  /**
-   * Creates a new, unconfigured builder for UML model obfuscators.
-   */
-  def static create() {
-    new UMLObfuscatorBuilder
-  }
-
-  /**
-   * Sets the input of the built obfuscator
-   */
-  def setInput(ResourceSet inputResourceSet) {
-    inputRS = inputResourceSet
-    return this
-  }
-
-  /**
-   * Sets the filter used in the built obfuscator.
-   * See {@link ResourceFilter} for details.
-   */
-  def setFilter(ResourceFilter filter) {
-    this.filter = filter
-    return this
-  }
-
-  /**
-   * Sets the salt used for obfuscating String values.
-   * See {@link StringObfuscator} for details.
-   */
-  def setSalt(String salt) {
-    saltString = salt
-    return this
-  }
-  
-  def setTraceMap(Map<String,String> obfuscationMap) {
-  	this.obfuscationMap = obfuscationMap
-  	return this
-  }
-
-  def getSeed(){
-    return seedString
-  }
-  
-  def getSalt(){
-    return saltString
-  }
-
-  /**
-   * Sets the seed used for obfuscating String values.
-   * See {@link StringObfuscator} for details.
-   */
-  def setSeed(String seed) {
-    seedString = seed
-    return this
-  }
-
-  /**
-   * Returns the {@link SimpleEMFModelObfuscator} instance built using the current configuration of the builder. 
-   */
-  def build() {
-    Preconditions.checkState(inputRS != null, "Input resource set cannot be null")
-    Preconditions.checkState(seedString != null, "Seed cannot be null")
-    Preconditions.checkState(saltString != null, "Salt cannot be null (empty string allowed)")
-    val SimpleUMLObfuscator obfuscator = new SimpleUMLObfuscator()
-    obfuscator.inputResourceSet = inputRS
-    obfuscator.filter = filter
-    obfuscator.stringObfuscator = new StringObfuscator(seedString, saltString, "o")
-    if(obfuscationMap!=null) {
-    	obfuscator.obfuscationMap = obfuscationMap
-    	obfuscator.trace = true
+    /**
+     * Hiding constructor of builder
+     */
+    protected new() {
+        super()
+        super.salt = ObfuscatorUtil.generateBase36RandomString(4)
+        super.prefix = "o"
     }
-    return obfuscator
-  }
+
+    /**
+     * Creates a new, unconfigured builder for UML model obfuscators.
+     */
+    def static create() {
+        new UMLObfuscatorBuilder
+    }
+
+    override protected createObfuscator() {
+        return new SimpleUMLObfuscator()
+    }
+    
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.viatra.modelobfuscator.runtime.uml/src/org/eclipse/viatra/modelobfuscator/emf/uml/UMLProfileReplacerBuilder.xtend b/plugins/org.eclipse.viatra.modelobfuscator.runtime.uml/src/org/eclipse/viatra/modelobfuscator/emf/uml/UMLProfileReplacerBuilder.xtend
index ba3ed6a..6a31db4 100644
--- a/plugins/org.eclipse.viatra.modelobfuscator.runtime.uml/src/org/eclipse/viatra/modelobfuscator/emf/uml/UMLProfileReplacerBuilder.xtend
+++ b/plugins/org.eclipse.viatra.modelobfuscator.runtime.uml/src/org/eclipse/viatra/modelobfuscator/emf/uml/UMLProfileReplacerBuilder.xtend
@@ -10,16 +10,19 @@
  *******************************************************************************/
 package org.eclipse.viatra.modelobfuscator.emf.uml
 
+import com.google.common.base.Preconditions
+import java.math.BigInteger
 import org.eclipse.uml2.uml.Model
 import org.eclipse.uml2.uml.Profile
-import com.google.common.base.Preconditions
 import org.eclipse.viatra.modelobfuscator.util.StringObfuscator
 
 class UMLProfileReplacerBuilder {
 	private Model inputModel
 	private Profile newProfile
-	private String seedString
-	
+	private BigInteger seedNumber
+    private String prefix = ""
+	private String saltString = ""
+    
 	protected new() {}
 	
 	def static create() {
@@ -36,20 +39,58 @@
 		return this
 	}
 	
-	def setSeed(String seedString) {
-		this.seedString = seedString
-		return this
-	}
+	/**
+     * Sets the seed used for obfuscating String values.
+     * See {@link StringObfuscator} for details.
+     * <p>
+     * Must be a base 36 number!
+     * 
+     * @throw NumberFormatException if seed is not base 36
+     */
+    @Deprecated
+    def setSeed(String seed) {
+        seedNumber = new BigInteger(seed, 36)
+        return this
+    }
+
+    /**
+     * Sets the seed used for obfuscating String values.
+     * See {@link StringObfuscator} for details.
+     */
+    def setSeed(BigInteger seed) {
+        seedNumber = seed
+        return this
+    }
+    
+    /**
+     * Sets the salt used for obfuscating String values.
+     * See {@link StringObfuscator} for details.
+     * 
+     */
+    def setSalt(String salt) {
+        saltString = salt
+        return this
+    }
+    
+    /**
+     * Sets the prefix used for obfuscating String values.
+     * See {@link StringObfuscator} for details.
+     */
+    def setPrefix(String prefix) {
+        this.prefix = prefix
+        return this
+    }
 	
 	def build() {
     	Preconditions.checkState(inputModel != null, "Input model cannot be null")
     	Preconditions.checkState(newProfile != null, "New profile cannot be null")
-    	Preconditions.checkState(seedString != null, "Seed string cannot be null")
-    	val SimpleUMLProfileReplacer matcher = new SimpleUMLProfileReplacer()
-    	matcher.inputModel = inputModel
-    	matcher.newProfile = newProfile
-    	matcher.seedString = seedString
-    	matcher.stringObfuscator = new StringObfuscator(seedString, "", "o")
-    	return matcher
+    	Preconditions.checkState(seedNumber != null, "Salt string cannot be null")
+    	Preconditions.checkState(prefix != null, "Prefix cannot be null (empty string allowed)")
+        Preconditions.checkState(saltString != null, "Salt cannot be null (empty string allowed)")
+        val SimpleUMLProfileReplacer replacer = new SimpleUMLProfileReplacer()
+    	replacer.inputModel = inputModel
+    	replacer.newProfile = newProfile
+    	replacer.stringObfuscator = new StringObfuscator(seedNumber, saltString, prefix)
+    	return replacer
 	}
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.viatra.modelobfuscator.runtime/src/org/eclipse/viatra/modelobfuscator/emf/simple/EMFModelObfuscatorBuilder.xtend b/plugins/org.eclipse.viatra.modelobfuscator.runtime/src/org/eclipse/viatra/modelobfuscator/emf/simple/EMFModelObfuscatorBuilder.xtend
index 3af8360..a7c74b7 100644
--- a/plugins/org.eclipse.viatra.modelobfuscator.runtime/src/org/eclipse/viatra/modelobfuscator/emf/simple/EMFModelObfuscatorBuilder.xtend
+++ b/plugins/org.eclipse.viatra.modelobfuscator.runtime/src/org/eclipse/viatra/modelobfuscator/emf/simple/EMFModelObfuscatorBuilder.xtend
@@ -4,17 +4,18 @@
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
- *
+ * 
  * Contributors:
  *   Abel Hegedus - initial API and implementation
  *******************************************************************************/
 package org.eclipse.viatra.modelobfuscator.emf.simple
 
+import com.google.common.base.Preconditions
+import java.util.Map
 import org.eclipse.emf.ecore.resource.ResourceSet
 import org.eclipse.viatra.modelobfuscator.util.ObfuscatorUtil
 import org.eclipse.viatra.modelobfuscator.util.StringObfuscator
-import com.google.common.base.Preconditions
-import java.util.Map
+import java.math.BigInteger
 
 /**
  * Builder API for setting up an EMF obfuscator. Currently the only implementation that can
@@ -24,97 +25,127 @@
  * <p/>The builder allows setting a seed and a salt for the obfuscator, which is used when initializing
  * the {@link StringObfuscator}, thus supporting reproducibility and restoration.
  * 
- * <p/>The default value of the seed is a random, 32 character long, hexadecimal string created by
- * {@link ObfuscatorUtil#generateHexSeed}. The default value of the salt is empty.
+ * <p/>The default value of the seed is a random, 32 character long, base36 string created by
+ * {@link ObfuscatorUtil#generateBase36RandomString}. The default value of the salt is empty.
  * 
  * @author Abel Hegedus
- *
+ * 
  */
 class EMFModelObfuscatorBuilder {
 
-  private ResourceSet inputRS
-  private ResourceFilter filter
-  private String saltString = ""
-  private String seedString = ObfuscatorUtil.generateHexSeed(32)
-  private Map<String,String> obfuscationMap = null
+    private ResourceSet inputRS
+    private ResourceFilter filter
+    private String saltString = ""
+    private BigInteger seedNumber = new BigInteger(ObfuscatorUtil.generateBase36RandomString(32), 36)
+    private String prefix = ""
+    private Map<String, String> obfuscationMap = null
 
-  /**
-   * Hiding constructor of builder
-   */
-  protected new() {
-  }
-
-  /**
-   * Creates a new, unconfigured builder for EMF model obfuscators.
-   */
-  def static create() {
-    new EMFModelObfuscatorBuilder
-  }
-
-  /**
-   * Sets the input of the built obfuscator
-   */
-  def setInput(ResourceSet inputResourceSet) {
-    inputRS = inputResourceSet
-    return this
-  }
-
-  /**
-   * Sets the filter used in the built obfuscator.
-   * See {@link ResourceFilter} for details.
-   */
-  def setFilter(ResourceFilter filter) {
-    this.filter = filter
-    return this
-  }
-
-  /**
-   * Sets the salt used for obfuscating String values.
-   * See {@link StringObfuscator} for details.
-   */
-  def setSalt(String salt) {
-    saltString = salt
-    return this
-  }
-  
-  def setTraceMap(Map<String,String> obfuscationMap) {
-  	this.obfuscationMap = obfuscationMap
-  	return this
-  }
-
-  def getSeed(){
-    return seedString
-  }
-  
-  def getSalt(){
-    return saltString
-  }
-
-  /**
-   * Sets the seed used for obfuscating String values.
-   * See {@link StringObfuscator} for details.
-   */
-  def setSeed(String seed) {
-    seedString = seed
-    return this
-  }
-
-  /**
-   * Returns the {@link SimpleEMFModelObfuscator} instance built using the current configuration of the builder. 
-   */
-  def build() {
-    Preconditions.checkState(inputRS != null, "Input resource set cannot be null")
-    Preconditions.checkState(seedString != null, "Seed cannot be null")
-    Preconditions.checkState(saltString != null, "Salt cannot be null (empty string allowed)")
-    val obfuscator = new SimpleEMFModelObfuscator()
-    obfuscator.inputResourceSet = inputRS
-    obfuscator.filter = filter
-    obfuscator.stringObfuscator = new StringObfuscator(seedString, saltString)
-    if(obfuscationMap!=null) {
-    	obfuscator.obfuscationMap = obfuscationMap
-    	obfuscator.trace = true
+    /**
+     * Hiding constructor of builder
+     */
+    protected new() {
     }
-    return obfuscator
-  }
+
+    /**
+     * Creates a new, unconfigured builder for EMF model obfuscators.
+     */
+    def static create() {
+        new EMFModelObfuscatorBuilder
+    }
+
+    /**
+     * Sets the input of the built obfuscator
+     */
+    def setInput(ResourceSet inputResourceSet) {
+        inputRS = inputResourceSet
+        return this
+    }
+
+    /**
+     * Sets the filter used in the built obfuscator.
+     * See {@link ResourceFilter} for details.
+     */
+    def setFilter(ResourceFilter filter) {
+        this.filter = filter
+        return this
+    }
+
+    /**
+     * Sets the salt used for obfuscating String values.
+     * See {@link StringObfuscator} for details.
+     * 
+     */
+    def setSalt(String salt) {
+        saltString = salt
+        return this
+    }
+
+    def setTraceMap(Map<String, String> obfuscationMap) {
+        this.obfuscationMap = obfuscationMap
+        return this
+    }
+
+    def getSeed() {
+        return seedNumber.toString(36)
+    }
+
+    def getSalt() {
+        return saltString
+    }
+
+    /**
+     * Sets the seed used for obfuscating String values.
+     * See {@link StringObfuscator} for details.
+     * <p>
+     * Must be a base 36 number!
+     * 
+     * @throw NumberFormatException if seed is not base 36
+     */
+    @Deprecated
+    def setSeed(String seed) {
+        seedNumber = new BigInteger(seed, 36)
+        return this
+    }
+
+    /**
+     * Sets the seed used for obfuscating String values.
+     * See {@link StringObfuscator} for details.
+     */
+    def setSeed(BigInteger seed) {
+        seedNumber = seed
+        return this
+    }
+
+    /**
+     * Sets the prefix used for obfuscating String values.
+     * See {@link StringObfuscator} for details.
+     */
+    def setPrefix(String prefix) {
+        this.prefix = prefix
+        return this
+    }
+
+    /**
+     * Returns the {@link SimpleEMFModelObfuscator} instance built using the current configuration of the builder. 
+     */
+    def AbstractModelObfuscator build() {
+        Preconditions.checkState(inputRS != null, "Input resource set cannot be null")
+        Preconditions.checkState(seedNumber != null, "Seed cannot be null")
+        Preconditions.checkState(prefix != null, "Prefix cannot be null (empty string allowed)")
+        Preconditions.checkState(saltString != null, "Salt cannot be null (empty string allowed)")
+        val obfuscator = createObfuscator()
+        obfuscator.inputResourceSet = inputRS
+        obfuscator.filter = filter
+        obfuscator.stringObfuscator = new StringObfuscator(seedNumber, saltString, prefix)
+        if (obfuscationMap != null) {
+            obfuscator.obfuscationMap = obfuscationMap
+            obfuscator.trace = true
+        }
+        return obfuscator
+    }
+
+    protected def AbstractModelObfuscator createObfuscator() {
+        return new SimpleEMFModelObfuscator()
+    }
 
 }
diff --git a/plugins/org.eclipse.viatra.modelobfuscator.runtime/src/org/eclipse/viatra/modelobfuscator/util/ObfuscatorUtil.java b/plugins/org.eclipse.viatra.modelobfuscator.runtime/src/org/eclipse/viatra/modelobfuscator/util/ObfuscatorUtil.java
index bdbcaeb..7947cd3 100644
--- a/plugins/org.eclipse.viatra.modelobfuscator.runtime/src/org/eclipse/viatra/modelobfuscator/util/ObfuscatorUtil.java
+++ b/plugins/org.eclipse.viatra.modelobfuscator.runtime/src/org/eclipse/viatra/modelobfuscator/util/ObfuscatorUtil.java
@@ -10,6 +10,9 @@
  *******************************************************************************/
 package org.eclipse.viatra.modelobfuscator.util;
 
+import java.math.BigInteger;
+import java.util.Random;
+
 import com.google.common.base.Preconditions;
 
 /**
@@ -26,18 +29,27 @@
         return out;
     }
     
+    
     public static String generateHexSeed(int length) {
-        Preconditions.checkArgument(length > 0,"Length must be positive");
-        // each fragment is 3 characters and we need an additional one
-        int noOfFragments = (length / 3) + 1;
-        StringBuilder sb = new StringBuilder(noOfFragments * 3);
-        for(int i = 0; i < noOfFragments; i++) {
-            // randomized string but first 3 chars not too random (typically "3fd")
-            String fragment = Long.toHexString(Double.doubleToLongBits(Math.random()));
-            // take only last 3 characters
-            sb.append(fragment.substring(3, 6));
-        }
-        return sb.substring(0, length);
+        return generateRandomString(length, 16);
+    }
+    
+    public static String generateBase36RandomString(int length) {
+        return generateRandomString(length, 36);
+    }
+
+    protected static String generateRandomString(int length, int radix) {
+        Preconditions.checkArgument(length > 0, "Length must be positive");
+        Preconditions.checkArgument(radix >= Character.MIN_RADIX, "Radix must be higher than or equal to Character.MIN_RADIX");
+        Preconditions.checkArgument(radix <= Character.MAX_RADIX, "Radix must be lower than or equal to Character.MAX_RADIX");
+        Random random = new Random();
+        // use BigInteger to generate random number (8 bit per byte)
+        BigInteger randomNumber = new BigInteger(length*8, random);
+        // convert to string with radix
+        String radixString = randomNumber.toString(radix);
+        // ignore the first character to avoid leading zeroes
+        String radixNoLeadingZeroes = radixString.substring(1, length+1);
+        return radixNoLeadingZeroes;  
     }
     
 }
diff --git a/plugins/org.eclipse.viatra.modelobfuscator.runtime/src/org/eclipse/viatra/modelobfuscator/util/StringObfuscator.xtend b/plugins/org.eclipse.viatra.modelobfuscator.runtime/src/org/eclipse/viatra/modelobfuscator/util/StringObfuscator.xtend
index 983399b..2b966d3 100644
--- a/plugins/org.eclipse.viatra.modelobfuscator.runtime/src/org/eclipse/viatra/modelobfuscator/util/StringObfuscator.xtend
+++ b/plugins/org.eclipse.viatra.modelobfuscator.runtime/src/org/eclipse/viatra/modelobfuscator/util/StringObfuscator.xtend
@@ -4,7 +4,7 @@
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
- *
+ * 
  * Contributors:
  *   Abel Hegedus - initial API and implementation
  *******************************************************************************/
@@ -13,68 +13,79 @@
 import org.eclipse.viatra.modelobfuscator.api.DataTypeObfuscator
 import com.google.common.io.BaseEncoding
 import com.google.common.base.Preconditions
+import java.math.BigInteger
 
 /**
  * @author Abel Hegedus
- *
+ * 
  */
 class StringObfuscator implements DataTypeObfuscator<String> {
-  
-  private String seed
-  private String salt
-  private String prefix
-  
-  new(String seed, String salt){
-    Preconditions.checkArgument(seed != null, "Seed cannot be null")
-    Preconditions.checkArgument(salt != null, "Salt cannot be null")
-    this.seed = seed
-    this.salt = salt
-    this.prefix = ""
-  }
-  
-  new(String seed, String salt, String prefix){
-    Preconditions.checkArgument(seed != null, "Seed cannot be null")
-    Preconditions.checkArgument(salt != null, "Salt cannot be null")
-    Preconditions.checkArgument(prefix != null, "Prefix cannot be null")
-    this.seed = seed
-    this.salt = salt
-    this.prefix = prefix
-  }
-  
-  override obfuscateData(String original) {
-    if(original != null){
-      val salted = salt + original
-      val obfuscatedBytes = ObfuscatorUtil.xorWithSeed(salted.bytes, seed.bytes)
-      return addPrefix(BaseEncoding.base16.encode(obfuscatedBytes))
+
+    private String seed
+    private String salt
+    private String prefix
+    private byte[] seedNumber
+
+    @Deprecated
+    new(String seed, String salt) {
+        this(seed, salt, "")
     }
-  }
-  
-  override restoreData(String obfuscated) {
-    if(obfuscated != null){
-      val obfuscatedBytes = BaseEncoding.base16.decode(removePrefix(obfuscated))
-      val salted = new String(ObfuscatorUtil.xorWithSeed(obfuscatedBytes, seed.bytes))
-      return salted.substring(salt.length)
+
+    @Deprecated
+    new(String seed, String salt, String prefix) {
+        Preconditions.checkArgument(seed != null, "Seed cannot be null")
+        Preconditions.checkArgument(salt != null, "Salt cannot be null")
+        Preconditions.checkArgument(prefix != null, "Prefix cannot be null")
+        this.seed = seed
+        this.seedNumber = seed.bytes
+        this.salt = salt
+        this.prefix = prefix
     }
-  }
-  
-  private def String addPrefix(String data) {
-  	return prefix+data
-  }
-  
-  private def String removePrefix(String data) {
-  	return data.substring(prefix.length)
-  }
-  
-  def getSeed(){
-    seed
-  }
-  
-  def getSalt(){
-    salt
-  }
-  
-  def getPrefix(){
-  	prefix
-  }
-  
-}
\ No newline at end of file
+
+    new(BigInteger seed, String salt, String prefix) {
+        Preconditions.checkArgument(seed != null, "Seed cannot be null")
+        Preconditions.checkArgument(salt != null, "Salt cannot be null")
+        Preconditions.checkArgument(prefix != null, "Prefix cannot be null")
+        this.seed = seed.toString(36)
+        this.seedNumber = seed.toByteArray.tail
+        this.salt = salt
+        this.prefix = prefix
+    }
+
+    override obfuscateData(String original) {
+        if (original != null) {
+            val salted = salt + original
+            val obfuscatedBytes = ObfuscatorUtil.xorWithSeed(salted.bytes, seedNumber)
+            return addPrefix(BaseEncoding.base16.encode(obfuscatedBytes))
+        }
+    }
+
+    override restoreData(String obfuscated) {
+        if (obfuscated != null) {
+            val obfuscatedBytes = BaseEncoding.base16.decode(removePrefix(obfuscated))
+            val salted = new String(ObfuscatorUtil.xorWithSeed(obfuscatedBytes, seedNumber))
+            return salted.substring(salt.length)
+        }
+    }
+
+    private def String addPrefix(String data) {
+        return prefix + data
+    }
+
+    private def String removePrefix(String data) {
+        return data.substring(prefix.length)
+    }
+
+    def getSeed() {
+        seed
+    }
+
+    def getSalt() {
+        salt
+    }
+
+    def getPrefix() {
+        prefix
+    }
+
+}
diff --git a/plugins/org.eclipse.viatra.modelobfuscator.runtime/src/org/eclipse/viatra/modelobfuscator/xml/XMLModelObfuscatorBuilder.xtend b/plugins/org.eclipse.viatra.modelobfuscator.runtime/src/org/eclipse/viatra/modelobfuscator/xml/XMLModelObfuscatorBuilder.xtend
index 983dafd..31ee782 100644
--- a/plugins/org.eclipse.viatra.modelobfuscator.runtime/src/org/eclipse/viatra/modelobfuscator/xml/XMLModelObfuscatorBuilder.xtend
+++ b/plugins/org.eclipse.viatra.modelobfuscator.runtime/src/org/eclipse/viatra/modelobfuscator/xml/XMLModelObfuscatorBuilder.xtend
@@ -4,17 +4,18 @@
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
- *
+ * 
  * Contributors:
  *   Abel Hegedus - initial API and implementation
  *******************************************************************************/
 package org.eclipse.viatra.modelobfuscator.xml
 
+import com.google.common.base.Preconditions
 import java.io.InputStream
 import java.io.OutputStream
+import java.math.BigInteger
 import org.eclipse.viatra.modelobfuscator.util.ObfuscatorUtil
 import org.eclipse.viatra.modelobfuscator.util.StringObfuscator
-import com.google.common.base.Preconditions
 
 /**
  * Builder API for setting up an XML obfuscator. Currently the only implementation that can
@@ -28,95 +29,111 @@
  * {@link ObfuscatorUtil#generateHexSeed}. The default value of the salt is empty.
  * 
  * @author Abel Hegedus
- *
+ * 
  */
 class XMLModelObfuscatorBuilder {
-  
-  private InputStream inputStream
-  private OutputStream outputStream
-  private extension XMLSchemaConfiguration config
-  protected extension StringObfuscator stringObfuscator
-  private String saltString = ""
-  private String seedString = ObfuscatorUtil.generateHexSeed(32);
-  
-  /**
-   * Hiding constructor of builder
-   */
-  protected new() {
-  }
-  
-  /**
-   * Creates a new, unconfigured builder for XML model obfuscators.
-   */
-  def static create(){
-    new XMLModelObfuscatorBuilder
-  }
-  
-  /**
-   * Sets the input of the built obfuscator
-   */
-  def setInput(InputStream input){
-    inputStream = input
-    return this
-  }
-  
-  /**
-   * Sets the output of the built obfuscator
-   */
-  def setOutput(OutputStream output){
-    outputStream = output
-    return this
-  }
-  
-  /**
-   * Sets the configuration used for selecting what to obfuscate.
-   * See {@link XMLSchemaConfiguration} for details.
-   */
-  def setSchemaConfiguration(XMLSchemaConfiguration configuration){
-    this.config = configuration
-    return this
-  }
-  
-  /**
-   * Sets the salt used for obfuscating String values.
-   * See {@link StringObfuscator} for details.
-   */
-  def setSalt(String salt){
-    saltString = salt
-    return this
-  }
-  
-  /**
-   * Sets the seed used for obfuscating String values.
-   * See {@link StringObfuscator} for details.
-   */
-  def setSeed(String seed){
-    seedString = seed
-    return this
-  }
-  
-  def getSeed(){
-    return seedString
-  }
-  
-  def getSalt(){
-    return saltString
-  }
-  
-  /**
-   * Returns the {@link XMLModelObfuscator} instance built using the current configuration of the builder. 
-   */
-  def build(){
-    Preconditions.checkState(inputStream != null, "Input resource set cannot be null")
-    Preconditions.checkState(outputStream != null, "Output resource set cannot be null")
-    Preconditions.checkState(seedString != null, "Seed cannot be null")
-    Preconditions.checkState(saltString != null, "Salt cannot be null (empty string allowed)")
-    val obfuscator = new XMLModelObfuscator()
-    obfuscator.inputStream = inputStream
-    obfuscator.outputStream = outputStream
-    obfuscator.config = config
-    obfuscator.stringObfuscator = new StringObfuscator(seedString, saltString)
-    return obfuscator
-  }
-  
-}
\ No newline at end of file
+
+    private InputStream inputStream
+    private OutputStream outputStream
+    private extension XMLSchemaConfiguration config
+    protected extension StringObfuscator stringObfuscator
+    private String saltString = ""
+    private String prefix = ""
+    private BigInteger seedNumber = new BigInteger(ObfuscatorUtil.generateBase36RandomString(32), 36)
+
+    /**
+     * Hiding constructor of builder
+     */
+    protected new() {
+    }
+
+    /**
+     * Creates a new, unconfigured builder for XML model obfuscators.
+     */
+    def static create() {
+        new XMLModelObfuscatorBuilder
+    }
+
+    /**
+     * Sets the input of the built obfuscator
+     */
+    def setInput(InputStream input) {
+        inputStream = input
+        return this
+    }
+
+    /**
+     * Sets the output of the built obfuscator
+     */
+    def setOutput(OutputStream output) {
+        outputStream = output
+        return this
+    }
+
+    /**
+     * Sets the configuration used for selecting what to obfuscate.
+     * See {@link XMLSchemaConfiguration} for details.
+     */
+    def setSchemaConfiguration(XMLSchemaConfiguration configuration) {
+        this.config = configuration
+        return this
+    }
+
+    /**
+     * Sets the salt used for obfuscating String values.
+     * See {@link StringObfuscator} for details.
+     */
+    def setSalt(String salt) {
+        saltString = salt
+        return this
+    }
+
+    /**
+     * Sets the seed used for obfuscating String values.
+     * See {@link StringObfuscator} for details.
+     * <p>
+     * Must be a base 36 number!
+     * 
+     * @throw NumberFormatException if seed is not base 36
+     */
+    @Deprecated
+    def setSeed(String seed) {
+        seedNumber = new BigInteger(seed, 36)
+        return this
+    }
+
+    /**
+     * Sets the seed used for obfuscating String values.
+     * See {@link StringObfuscator} for details.
+     */
+    def setSeed(BigInteger seed) {
+        seedNumber = seed
+        return this
+    }
+
+    def getSeed() {
+        return seedNumber.toString(36)
+    }
+
+    def getSalt() {
+        return saltString
+    }
+
+    /**
+     * Returns the {@link XMLModelObfuscator} instance built using the current configuration of the builder. 
+     */
+    def build() {
+        Preconditions.checkState(inputStream != null, "Input resource set cannot be null")
+        Preconditions.checkState(outputStream != null, "Output resource set cannot be null")
+        Preconditions.checkState(seedNumber != null, "Seed cannot be null")
+        Preconditions.checkState(prefix != null, "Prefix cannot be null (empty string allowed)")
+        Preconditions.checkState(saltString != null, "Salt cannot be null (empty string allowed)")
+        val obfuscator = new XMLModelObfuscator()
+        obfuscator.inputStream = inputStream
+        obfuscator.outputStream = outputStream
+        obfuscator.config = config
+        obfuscator.stringObfuscator = new StringObfuscator(seedNumber, saltString, prefix)
+        return obfuscator
+    }
+
+}
diff --git a/plugins/org.eclipse.viatra.modelobfuscator.tests/src/org/eclipse/viatra/modelobfuscator/tests/SimpleUMLObfuscatorTest.xtend b/plugins/org.eclipse.viatra.modelobfuscator.tests/src/org/eclipse/viatra/modelobfuscator/tests/SimpleUMLObfuscatorTest.xtend
index be03980..3e4c43f 100644
--- a/plugins/org.eclipse.viatra.modelobfuscator.tests/src/org/eclipse/viatra/modelobfuscator/tests/SimpleUMLObfuscatorTest.xtend
+++ b/plugins/org.eclipse.viatra.modelobfuscator.tests/src/org/eclipse/viatra/modelobfuscator/tests/SimpleUMLObfuscatorTest.xtend
@@ -23,7 +23,7 @@
 class SimpleUMLObfuscatorTest {
 	extension UMLFactory umlFactory = UMLFactory.eINSTANCE
 	private static final String TESTMODEL_NAME = "MyModel"
-
+  
   @Test
   def void invokeObfuscatorNoSaltTest() {
 
diff --git a/plugins/org.eclipse.viatra.modelobfuscator.tests/src/org/eclipse/viatra/modelobfuscator/tests/SimpleUMLProfileReplacerTest.xtend b/plugins/org.eclipse.viatra.modelobfuscator.tests/src/org/eclipse/viatra/modelobfuscator/tests/SimpleUMLProfileReplacerTest.xtend
index 8d6e281..06568a1 100644
--- a/plugins/org.eclipse.viatra.modelobfuscator.tests/src/org/eclipse/viatra/modelobfuscator/tests/SimpleUMLProfileReplacerTest.xtend
+++ b/plugins/org.eclipse.viatra.modelobfuscator.tests/src/org/eclipse/viatra/modelobfuscator/tests/SimpleUMLProfileReplacerTest.xtend
@@ -23,6 +23,7 @@
 
 import static org.junit.Assert.*
 import org.eclipse.uml2.uml.Stereotype
+import java.math.BigInteger
 
 class SimpleUMLProfileReplacerTest {
 	private static final String SEED = "990d6121017dd960315eca3176a73bde"
@@ -56,7 +57,7 @@
 		val replacer = UMLProfileReplacerBuilder.create
 												.setInput(model)
 												.setNewProfile(profileObfuscated)
-												.setSeed(SEED).build
+												.setSeed(new BigInteger(SEED,16)).build
 		replacer.replace
 		val stringObfuscator = replacer.stringObfuscator
 		val myStereotype = profileOriginal.getMember("MyStereotype") as Stereotype
diff --git a/plugins/org.eclipse.viatra.modelobfuscator.ui.uml/src/org/eclipse/viatra/modelobfuscator/ui/uml/handlers/UMLProfileReplacerHandler.java b/plugins/org.eclipse.viatra.modelobfuscator.ui.uml/src/org/eclipse/viatra/modelobfuscator/ui/uml/handlers/UMLProfileReplacerHandler.java
index e5857b8..a0165d3 100644
--- a/plugins/org.eclipse.viatra.modelobfuscator.ui.uml/src/org/eclipse/viatra/modelobfuscator/ui/uml/handlers/UMLProfileReplacerHandler.java
+++ b/plugins/org.eclipse.viatra.modelobfuscator.ui.uml/src/org/eclipse/viatra/modelobfuscator/ui/uml/handlers/UMLProfileReplacerHandler.java
@@ -10,6 +10,7 @@
  *******************************************************************************/
 package org.eclipse.viatra.modelobfuscator.ui.uml.handlers;
 
+import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -88,6 +89,11 @@
 								@Override
 								public String isValid(String newText) {
 									if (newText.length()>0) {
+									    try{
+									        new BigInteger(newText, 36);
+									    } catch (NumberFormatException e) {
+									        return "Seed must be base 36 number";
+									    }
 										return null;
 									}
 									return "Invalid seed";
@@ -109,7 +115,7 @@
 			final SimpleUMLProfileReplacer matcher = UMLProfileReplacerBuilder.create()
 					.setInput(selectedModel)
 					.setNewProfile(selectedProfile)
-					.setSeed(seedString).build();
+					.setSeed(new BigInteger(seedString, 36)).build();
 			
 			AbstractCommand replaceCommand = new AbstractCommand("Replacing profile") {
 
diff --git a/plugins/org.eclipse.viatra.modelobfuscator.ui/src/org/eclipse/viatra/modelobfuscator/ui/handlers/EMFModelObfuscatorHandler.java b/plugins/org.eclipse.viatra.modelobfuscator.ui/src/org/eclipse/viatra/modelobfuscator/ui/handlers/EMFModelObfuscatorHandler.java
index 0586ae0..0cdc376 100644
--- a/plugins/org.eclipse.viatra.modelobfuscator.ui/src/org/eclipse/viatra/modelobfuscator/ui/handlers/EMFModelObfuscatorHandler.java
+++ b/plugins/org.eclipse.viatra.modelobfuscator.ui/src/org/eclipse/viatra/modelobfuscator/ui/handlers/EMFModelObfuscatorHandler.java
@@ -14,6 +14,7 @@
 import org.eclipse.emf.ecore.resource.Resource;
 import org.eclipse.emf.ecore.resource.ResourceSet;
 import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.viatra.modelobfuscator.emf.simple.AbstractModelObfuscator;
 import org.eclipse.viatra.modelobfuscator.emf.simple.EMFModelObfuscatorBuilder;
 import org.eclipse.viatra.modelobfuscator.emf.simple.ResourceFilter;
 import org.eclipse.viatra.modelobfuscator.emf.simple.SimpleEMFModelObfuscator;
@@ -34,7 +35,7 @@
 public class EMFModelObfuscatorHandler extends AbstractModelObfuscatorHandler {
 
 	@Override
-	protected SimpleEMFModelObfuscator createModelObfuscator(ResourceSet resourceSet, final EditingDomain editingDomain, ExecutionEvent event ) {
+	protected AbstractModelObfuscator createModelObfuscator(ResourceSet resourceSet, final EditingDomain editingDomain, ExecutionEvent event ) {
 		return EMFModelObfuscatorBuilder.create().setInput(resourceSet)
                 .setFilter(new ResourceFilter() {
                     @Override