Skip to content

请教 Bash 脚本如何请求开启了访问密钥的配置项 #5115

Closed Answered by dosubot bot
gotnix asked this question in Q&A
Discussion options

You must be logged in to vote

嗨,@gotnix!很高兴再次看到你在这里提问。希望你近期一切都好!

根据您提供的上下文,我发现了一个类似的问题#5114,其中提供了一个修改后的脚本,可能会对您有所帮助。这个脚本在构造签名字符串时使用了$'\n'作为分隔符,而不是"\n"。此外,它还使用了jq命令来进行URL编码,并在curl命令中使用了-G选项和--data-urlencode参数。以下是修改后的脚本:

#!/bin/bash

# Function to sign a string with HmacSHA1
function signature() {
  # Get arguments: timestamp in milliseconds, path with query, and secret
  timestamp_ms="$1"
  path_with_query="$2"
  secret="$3"

  # Define delimiter for string construction
  delimiter=$'\n'

  # Construct string to sign
  string_to_sign="$timestamp_ms$delimiter$path_with_query"

  # Use openssl for HmacSHA1 (assuming it's installed)
  signature=$(echo -n "${string_to_sign}" | openssl dgst -sha1 -hmac "${secret}" -binary |

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by gotnix
Comment options

You must be logged in to vote
1 reply
@dosubot
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant