@@ -1413,7 +1413,8 @@ func init() {
14131413 return nil , errors .New ("at least two arguments needed" )
14141414 }
14151415
1416- n := - 1
1416+ inputs := make ([][]byte , 0 , len (args ))
1417+ maxLen := 0
14171418 for _ , arg := range args {
14181419 var b []byte
14191420 switch v := arg .(type ) {
@@ -1424,21 +1425,19 @@ func init() {
14241425 default :
14251426 return nil , fmt .Errorf ("invalid argument type %T" , arg )
14261427 }
1427- if n == - 1 {
1428- n = len (b )
1429- } else if len (b ) != n {
1430- return nil , errors .New ("all arguments must have the same length" )
1428+ if len (b ) == 0 {
1429+ return nil , errors .New ("empty arguments are not allowed" )
1430+ }
1431+ inputs = append (inputs , b )
1432+ if len (b ) > maxLen {
1433+ maxLen = len (b )
14311434 }
14321435 }
14331436
1434- result := make ([]byte , n )
1435- for i := 0 ; i < n ; i ++ {
1436- for _ , arg := range args {
1437- b , ok := arg .([]byte )
1438- if ! ok {
1439- b = []byte (arg .(string ))
1440- }
1441- result [i ] ^= b [i ]
1437+ result := make ([]byte , maxLen )
1438+ for i := 0 ; i < maxLen ; i ++ {
1439+ for _ , b := range inputs {
1440+ result [i ] ^= b [i % len (b )]
14421441 }
14431442 }
14441443
@@ -1739,8 +1738,8 @@ func AddMultiSignatureHelperFunction(key string, signatureparts []string, cachea
17391738 return AddFunction (function )
17401739}
17411740
1742- func GetFunctionNames (heperFunctions map [string ]govaluate.ExpressionFunction ) []string {
1743- return maputils .GetKeys (heperFunctions )
1741+ func GetFunctionNames (helperFunctions map [string ]govaluate.ExpressionFunction ) []string {
1742+ return maputils .GetKeys (helperFunctions )
17441743}
17451744
17461745// GetPrintableDslFunctionSignatures returns the function signatures for the
0 commit comments