@@ -426,24 +426,25 @@ public override void ToString(StringBuilder stringBuilder, bool addBrackets)
426426 }
427427 }
428428
429- internal class Function_HMACMD5 : Function_N
429+ internal class Function_HMACMD5 : Function_3
430430 {
431- public Function_HMACMD5 ( FunctionBase [ ] funcs ) : base ( funcs )
431+ public Function_HMACMD5 ( FunctionBase func1 , FunctionBase func2 , FunctionBase func3 ) : base ( func1 , func2 , func3 )
432432 {
433433 }
434434
435435 public override Operand Calculate ( AlgorithmEngine work )
436436 {
437- var args = new List < Operand > ( ) ; int index = 1 ;
438- foreach ( var item in funcs ) { var a = item . Calculate ( work ) . ToText ( "Function '{0}' parameter {1} is error!" , "HmacMD5" , index ++ ) ; if ( a . IsError ) { return a ; } args . Add ( a ) ; }
437+ var args1 = func1 . Calculate ( work ) ; if ( args1 . Type != OperandType . TEXT ) { args1 = args1 . ToText ( "Function '{0}' parameter {1} is error!" , "HmacMD5" , 1 ) ; if ( args1 . IsError ) return args1 ; }
438+ var args2 = func2 . Calculate ( work ) ; if ( args2 . Type != OperandType . TEXT ) { args2 = args2 . ToText ( "Function '{0}' parameter {1} is error!" , "HmacMD5" , 2 ) ; if ( args2 . IsError ) return args2 ; }
439439 try {
440440 Encoding encoding ;
441- if ( args . Count == 2 ) {
441+ if ( func3 == null ) {
442442 encoding = Encoding . UTF8 ;
443443 } else {
444- encoding = Encoding . GetEncoding ( args [ 2 ] . TextValue ) ;
444+ var args3 = func3 . Calculate ( work ) ; if ( args3 . Type != OperandType . TEXT ) { args3 = args3 . ToText ( "Function '{0}' parameter {1} is error!" , "HmacMD5" , 3 ) ; if ( args3 . IsError ) return args3 ; }
445+ encoding = Encoding . GetEncoding ( args3 . TextValue ) ;
445446 }
446- var t = Hash . GetHmacMd5String ( encoding . GetBytes ( args [ 0 ] . TextValue ) , args [ 1 ] . TextValue ) ;
447+ var t = Hash . GetHmacMd5String ( encoding . GetBytes ( args1 . TextValue ) , args2 . TextValue ) ;
447448 return Operand . Create ( t ) ;
448449 } catch ( Exception ex ) {
449450 return Operand . Error ( "Function 'HmacMD5' is error!" + ex . Message ) ;
@@ -455,24 +456,25 @@ public override void ToString(StringBuilder stringBuilder, bool addBrackets)
455456 }
456457 }
457458
458- internal class Function_HMACSHA1 : Function_N
459+ internal class Function_HMACSHA1 : Function_3
459460 {
460- public Function_HMACSHA1 ( FunctionBase [ ] funcs ) : base ( funcs )
461+ public Function_HMACSHA1 ( FunctionBase func1 , FunctionBase func2 , FunctionBase func3 ) : base ( func1 , func2 , func3 )
461462 {
462463 }
463464
464465 public override Operand Calculate ( AlgorithmEngine work )
465466 {
466- var args = new List < Operand > ( ) ; int index = 1 ;
467- foreach ( var item in funcs ) { var a = item . Calculate ( work ) . ToText ( "Function '{0}' parameter {1} is error!" , "HmacSHA1" , index ++ ) ; if ( a . IsError ) { return a ; } args . Add ( a ) ; }
467+ var args1 = func1 . Calculate ( work ) ; if ( args1 . Type != OperandType . TEXT ) { args1 = args1 . ToText ( "Function '{0}' parameter {1} is error!" , "HmacSHA1" , 1 ) ; if ( args1 . IsError ) return args1 ; }
468+ var args2 = func2 . Calculate ( work ) ; if ( args2 . Type != OperandType . TEXT ) { args2 = args2 . ToText ( "Function '{0}' parameter {1} is error!" , "HmacSHA1" , 2 ) ; if ( args2 . IsError ) return args2 ; }
468469 try {
469470 Encoding encoding ;
470- if ( args . Count == 2 ) {
471+ if ( func3 == null ) {
471472 encoding = Encoding . UTF8 ;
472473 } else {
473- encoding = Encoding . GetEncoding ( args [ 2 ] . TextValue ) ;
474+ var args3 = func3 . Calculate ( work ) ; if ( args3 . Type != OperandType . TEXT ) { args3 = args3 . ToText ( "Function '{0}' parameter {1} is error!" , "HmacSHA1" , 3 ) ; if ( args3 . IsError ) return args3 ; }
475+ encoding = Encoding . GetEncoding ( args3 . TextValue ) ;
474476 }
475- var t = Hash . GetHmacSha1String ( encoding . GetBytes ( args [ 0 ] . TextValue ) , args [ 1 ] . TextValue ) ;
477+ var t = Hash . GetHmacSha1String ( encoding . GetBytes ( args1 . TextValue ) , args2 . TextValue ) ;
476478 return Operand . Create ( t ) ;
477479 } catch ( Exception ex ) {
478480 return Operand . Error ( "Function 'HmacSHA1' is error!" + ex . Message ) ;
@@ -484,24 +486,25 @@ public override void ToString(StringBuilder stringBuilder, bool addBrackets)
484486 }
485487 }
486488
487- internal class Function_HMACSHA256 : Function_N
489+ internal class Function_HMACSHA256 : Function_3
488490 {
489- public Function_HMACSHA256 ( FunctionBase [ ] funcs ) : base ( funcs )
491+ public Function_HMACSHA256 ( FunctionBase func1 , FunctionBase func2 , FunctionBase func3 ) : base ( func1 , func2 , func3 )
490492 {
491493 }
492494
493495 public override Operand Calculate ( AlgorithmEngine work )
494496 {
495- var args = new List < Operand > ( ) ; int index = 1 ;
496- foreach ( var item in funcs ) { var a = item . Calculate ( work ) . ToText ( "Function '{0}' parameter {1} is error!" , "HmacSHA256" , index ++ ) ; if ( a . IsError ) { return a ; } args . Add ( a ) ; }
497+ var args1 = func1 . Calculate ( work ) ; if ( args1 . Type != OperandType . TEXT ) { args1 = args1 . ToText ( "Function '{0}' parameter {1} is error!" , "HmacSHA256" , 1 ) ; if ( args1 . IsError ) return args1 ; }
498+ var args2 = func2 . Calculate ( work ) ; if ( args2 . Type != OperandType . TEXT ) { args2 = args2 . ToText ( "Function '{0}' parameter {1} is error!" , "HmacSHA256" , 2 ) ; if ( args2 . IsError ) return args2 ; }
497499 try {
498500 Encoding encoding ;
499- if ( args . Count == 2 ) {
501+ if ( func3 == null ) {
500502 encoding = Encoding . UTF8 ;
501503 } else {
502- encoding = Encoding . GetEncoding ( args [ 2 ] . TextValue ) ;
504+ var args3 = func3 . Calculate ( work ) ; if ( args3 . Type != OperandType . TEXT ) { args3 = args3 . ToText ( "Function '{0}' parameter {1} is error!" , "HmacSHA256" , 3 ) ; if ( args3 . IsError ) return args3 ; }
505+ encoding = Encoding . GetEncoding ( args3 . TextValue ) ;
503506 }
504- var t = Hash . GetHmacSha256String ( encoding . GetBytes ( args [ 0 ] . TextValue ) , args [ 1 ] . TextValue ) ;
507+ var t = Hash . GetHmacSha256String ( encoding . GetBytes ( args1 . TextValue ) , args2 . TextValue ) ;
505508 return Operand . Create ( t ) ;
506509 } catch ( Exception ex ) {
507510 return Operand . Error ( "Function 'HmacSHA256' is error!" + ex . Message ) ;
@@ -513,24 +516,25 @@ public override void ToString(StringBuilder stringBuilder, bool addBrackets)
513516 }
514517 }
515518
516- internal class Function_HMACSHA512 : Function_N
519+ internal class Function_HMACSHA512 : Function_3
517520 {
518- public Function_HMACSHA512 ( FunctionBase [ ] funcs ) : base ( funcs )
521+ public Function_HMACSHA512 ( FunctionBase func1 , FunctionBase func2 , FunctionBase func3 ) : base ( func1 , func2 , func3 )
519522 {
520523 }
521524
522525 public override Operand Calculate ( AlgorithmEngine work )
523526 {
524- var args = new List < Operand > ( ) ; int index = 1 ;
525- foreach ( var item in funcs ) { var a = item . Calculate ( work ) . ToText ( "Function '{0}' parameter {1} is error!" , "HmacSHA512" , index ++ ) ; if ( a . IsError ) { return a ; } args . Add ( a ) ; }
527+ var args1 = func1 . Calculate ( work ) ; if ( args1 . Type != OperandType . TEXT ) { args1 = args1 . ToText ( "Function '{0}' parameter {1} is error!" , "HmacSHA512" , 1 ) ; if ( args1 . IsError ) return args1 ; }
528+ var args2 = func2 . Calculate ( work ) ; if ( args2 . Type != OperandType . TEXT ) { args2 = args2 . ToText ( "Function '{0}' parameter {1} is error!" , "HmacSHA512" , 2 ) ; if ( args2 . IsError ) return args2 ; }
526529 try {
527530 Encoding encoding ;
528- if ( args . Count == 2 ) {
531+ if ( func3 == null ) {
529532 encoding = Encoding . UTF8 ;
530533 } else {
531- encoding = Encoding . GetEncoding ( args [ 2 ] . TextValue ) ;
534+ var args3 = func3 . Calculate ( work ) ; if ( args3 . Type != OperandType . TEXT ) { args3 = args3 . ToText ( "Function '{0}' parameter {1} is error!" , "HmacSHA512" , 3 ) ; if ( args3 . IsError ) return args3 ; }
535+ encoding = Encoding . GetEncoding ( args3 . TextValue ) ;
532536 }
533- var t = Hash . GetHmacSha512String ( encoding . GetBytes ( args [ 0 ] . TextValue ) , args [ 1 ] . TextValue ) ;
537+ var t = Hash . GetHmacSha512String ( encoding . GetBytes ( args1 . TextValue ) , args2 . TextValue ) ;
534538 return Operand . Create ( t ) ;
535539 } catch ( Exception ex ) {
536540 return Operand . Error ( "Function 'HmacSHA512' is error!" + ex . Message ) ;
0 commit comments