diff --git a/apps/tools/xaal/tools/keygen.py b/apps/tools/xaal/tools/keygen.py
index cd0f6ea1257d428e421e04d0bb4cdb3a5f06b816..7d46bc9fee726d032092401a2e1a1c7fd663d946 100644
--- a/apps/tools/xaal/tools/keygen.py
+++ b/apps/tools/xaal/tools/keygen.py
@@ -1,17 +1,41 @@
-""" Tool to build a key pass for xAAL config file"""
+"""
+Tool to build a key pass for xAAL config file
+
+You can use it to get a key for xaal configuration file.
+This script support piping.
+
+$ echo xaal |xaal-keygen 
+
+"""
 
-from xaal.lib import tools
 import binascii
+import pysodium
+
+
+def pass2key(passphrase: str) -> bytes:
+    """Generate key from passphrase using libsodium"""
+    # This function is a cut / paste from xaal.lib.tools pass2key function.
+    # Check out this file for more information. This stuff avoid to import
+    # xaal.tools and messing w/ the xaal configuration file at the first
+    # install.
+    buf = passphrase.encode("utf-8")
+    KEY_BYTES = pysodium.crypto_pwhash_scryptsalsa208sha256_SALTBYTES  # 32
+    salt = ('\00' * KEY_BYTES).encode('utf-8')
+    opslimit = pysodium.crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE
+    memlimit = pysodium.crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE
+    key = pysodium.crypto_pwhash_scryptsalsa208sha256(KEY_BYTES, buf, salt, opslimit, memlimit)
+    return key
+
 
 def main():
     try:
         temp = input("Please enter your passphrase: ")
-        key  = tools.pass2key(temp)
+        key = pass2key(temp)
         print("Cut & Paste this key in your xAAL config-file")
-        print("key=%s"% binascii.hexlify(key).decode('utf-8'))
+        print("key=%s" % binascii.hexlify(key).decode('utf-8'))
     except KeyboardInterrupt:
         print("Bye Bye..")
-        
+
 
 if __name__ == '__main__':
     main()