Fixed keylength calculation. See PHPCRED-25
Fixed keylength calculation. See PHPCRED-25

--- a/Resources/main.js
+++ b/Resources/main.js
@@ -959,7 +959,7 @@
         enc += b.toString()+" ";
 
 	keypos++;
-	if (keypos >= key.length){ keypos = 0;}
+	if (keypos >= key[0].length){ keypos = 0;}
     }
 
 
@@ -988,7 +988,7 @@
         enc += String.fromCharCode(b);
 
 	keypos++;
-	if (keypos >= key.length){ keypos = 0;}
+	if (keypos >= key[0].length){ keypos = 0;}
     }
 
 return enc;

--- a/lib/crypto.php
+++ b/lib/crypto.php
@@ -65,10 +65,10 @@
 */
 function &xordstring($str,&$key){
 
-$keylength = strlen($key);
 $kpos = 0;
 $en = "";
 $k = explode(":",$key);
+$keylength = strlen($k[0]);
 $str = explode(" ",$str);
 
 foreach ($str as $string){
@@ -107,11 +107,12 @@
 */
 function xorestring(&$str,&$key){
 
-$keylength = strlen($key);
+
 $strlength = strlen($str);
 $kpos = 0;
 $en = "";
 $k = explode(":",$key);
+$keylength = strlen($k[0]);
 
 $i = 0;
 
@@ -395,3 +396,4 @@
 }
 
 ?>
+