You can use the `openssl`

to Calculate`SHA-1`

and `-binary`

output the digest in binary form.

Last piping convert binary-digest to Base-64.

```
echo -n mydata | openssl dgst -binary -sha1 | openssl base64
```

#### Explanation

##### Sending data (`mydata`

in this case) to STDOUT:

```
echo -n mydata
```

`-n`

flag remove new line (`\n`

) from output.

##### Calculating `SHA-1`

via OpenSSL:

```
openssl dgst -sha1
```

However, this command displays the `SHA-1`

in HEX mode, and for binary, the `-binary`

flag needs to be added:

```
openssl dgst -binary -sha1
```

##### Convert `SHA-1`

to `Base-64`

:

```
openssl base64
```

`sha1`

program outputs.