以下shell脚本行是什么意思?

时间:2018-11-07 13:35:25

标签: shell amazon-s3

Link to stack overflow page describing s3 curl

我是Shell脚本的新手,我需要了解以下行的含义:

@done   
@succesfulladdbeforewhen
Scenario Outline: Admin adds an alternate numbers entry with a phonenumber successfully
    Given the BW User is logged in with a <userlevel> Level Account
        And the AddAlternateNumbersEntry query parameter contains an existing userid within the scope of the BW User
        And the AddAlternateNumbersEntry post body contains an available phonenumber
    When the BW User submits the AddAlternateNumbersEntry request
    Then HTTP 201 should be returned
    And a new alternate numbers entry should be added

    Examples: User Levels
            | userlevel         |
            | System            |
            | Service Provider  |
            | Group             |
  1. 这是否意味着将signature=`/bin/echo -n "$stringToSign" | openssl sha1 -hmac ${s3Secret} -binary | base64` 的输出通过管道传输到/bin/echo -n "$stringToSign"

  2. openssl sha1 -hmac ${s3Secret} -binary是什么意思?

  3. /bin/echo -n的简单解释是什么?

  4. openssl sha1 -hmac对通过管道“ $ stringToSign”进行的操作是什么?是加密吗?

2 个答案:

答案 0 :(得分:2)

  1. -n : do not output the trailing newline 1
  2. sha1 refers to SHA-1 message disgest algorithm 2
  3. -hmac is the message authentication code 3
  4. 是的。如果您使用的是Linux系统,则可以执行openssl sha1 -h,将发现以下行:  -hmac key create hashed MAC with key

它使用您提供的密钥创建一个哈希。这是一个简单的cmdline示例。

$ echo -n "SomeStuff" | openssl sha1 -hmac key
(stdin)= c127d9119057757c0de8a1e081c1327c489c0eaa

并带有二进制

$ echo -n "SomeStuff" | openssl sha1 -hmac key -binary
�����2|H��

您可以将二进制文件存储在.hmac文件中。然后,您可以使用hmaccalc之类的软件来提供sha1hmac来为您的用例解密存储的二进制密钥。

有关更多信息。阅读随附链接中的手册。

答案 1 :(得分:1)

它通常用于基于SHA1算法(openssl命令部分)计算签名,并确保它仅包含ASCII字符(base64命令部分)。 @iamauser的答案对于底层解释是正确的。

例如:

 ~ export stringToSign='This a sample string that i do want to sign !!!'
 ~ signature=`/bin/echo -n "$stringToSign" | openssl sha1 -hmac ${s3Secret} -binary |      base64`
 ~ echo $signature
ZTRhYWVhMTZkYzZlZDZjNjJhNjMzNzliYTAyNTFkYzUxYjI5YWYwYQo=
相关问题