Skip to content

EsonDev PR #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .hdu-cli.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
net:
auth:
# i-HDU wifi login
#
# Manually method
# username always is your student id like 20051101
# password is what u know
# and put the file at your home directory
#
# Auto method
# hdu-cli net login --username 20051101 --password your-password
# After Testing on my Kali linux The ( -s / -d ) option seems not work correctly.
# There need further debugging.
username: 20051101
password: your-password
44 changes: 33 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,46 @@
go install github.com/hduhelp/hdu-cli@latest
```

<details>
<summary>Trouble shoot</summary>

> The Command may need root privilege
>
> and sometimes go env is not install completely on your root account (sudo mode)
>
> so try like `sudo $GOROOT/bin/go install github.com/hduhelp/hdu-cli@latest`
>
> By the way, if you follow the offical installation guide of GO, The goroot will be like /usr/local/go/
</details>

## Usage

### hdu-cli [command]
### hdu-cli [sub command]

### Available Commands:
### Available Sub Commands:

- completion generate the autocompletion script for the specified shell
- help Help about any command
- net i-hdu network auth cli
- completion
- generate the autocompletion script for the specified shell
- help
- Help about any command
- net
- i-hdu network auth cli

### Flags:

- --config string config file (default is $HOME/.hdu-cli.yaml)
- -h, --help help for hdu_cli
- -s, --save save config
- -V, --verbose show more info
- -v, --version version for hdu_cli
- --config string
- config file (default is $HOME/.hdu-cli.yaml)
- more detail see comments at [hdu-cli.yaml example](./.hdu-cli.yaml)
- -h, --help
- help for hdu_cli
- -s, --save
- save config
- -V, --verbose
- show more info
- -v, --version
- version for hdu_cli


Use "hdu_cli [command] --help" for more information about a command.
Use `hdu_cli [sub command] --help` for more information about a command.


13 changes: 13 additions & 0 deletions utils/str.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,24 @@ import (
"crypto/hmac"
"crypto/md5"
"crypto/sha1"
"encoding/base64"
"encoding/hex"
"fmt"
"io"
)

func B64encode(content string) string {
return base64.StdEncoding.EncodeToString([]byte(content))
}

func B64decode(content string) (string, error) {
data, err := base64.StdEncoding.DecodeString(content)
if err != nil {
return "", err
}
return string(data), nil
}

func Sha1(content string) string {
h := sha1.New()
h.Write([]byte(content))
Expand Down