File tree Expand file tree Collapse file tree 1 file changed +7
-11
lines changed
src/webserver/database/sqlpage_functions Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -757,14 +757,14 @@ async fn hmac<'a>(
757757 } ;
758758
759759 let algorithm = algorithm. as_deref ( ) . unwrap_or ( "sha256" ) ;
760-
760+
761761 // Parse algorithm and output format (e.g., "sha256" or "sha256-base64")
762762 let ( hash_algo, output_format) = if let Some ( ( algo, format) ) = algorithm. split_once ( '-' ) {
763763 ( algo, format)
764764 } else {
765765 ( algorithm, "hex" )
766766 } ;
767-
767+
768768 let result = match hash_algo. to_lowercase ( ) . as_str ( ) {
769769 "sha256" => {
770770 let mut mac = Hmac :: < Sha256 > :: new_from_slice ( key. as_bytes ( ) )
@@ -787,15 +787,11 @@ async fn hmac<'a>(
787787
788788 // Convert to requested output format
789789 let output = match output_format. to_lowercase ( ) . as_str ( ) {
790- "hex" => {
791- result. into_iter ( ) . fold ( String :: new ( ) , |mut acc, byte| {
792- write ! ( & mut acc, "{byte:02x}" ) . unwrap ( ) ;
793- acc
794- } )
795- }
796- "base64" => {
797- base64:: Engine :: encode ( & base64:: engine:: general_purpose:: STANDARD , result)
798- }
790+ "hex" => result. into_iter ( ) . fold ( String :: new ( ) , |mut acc, byte| {
791+ write ! ( & mut acc, "{byte:02x}" ) . unwrap ( ) ;
792+ acc
793+ } ) ,
794+ "base64" => base64:: Engine :: encode ( & base64:: engine:: general_purpose:: STANDARD , result) ,
799795 _ => {
800796 anyhow:: bail!(
801797 "Unsupported output format: {output_format}. Supported formats: hex, base64"
You can’t perform that action at this time.
0 commit comments