diff --git a/src/csi/backend/plugin/fusionstorage.go b/src/csi/backend/plugin/fusionstorage.go index f9e05843..0c64c4c0 100644 --- a/src/csi/backend/plugin/fusionstorage.go +++ b/src/csi/backend/plugin/fusionstorage.go @@ -7,7 +7,6 @@ import ( "github.com/Huawei/eSDK_K8S_Plugin/src/storage/fusionstorage/client" "github.com/Huawei/eSDK_K8S_Plugin/src/utils" "github.com/Huawei/eSDK_K8S_Plugin/src/utils/log" - "github.com/Huawei/eSDK_K8S_Plugin/src/utils/pwd" ) const ( @@ -35,13 +34,8 @@ func (p *FusionStoragePlugin) init(config map[string]interface{}, keepLogin bool return errors.New("password must be provided") } - decrypted, err := pwd.Decrypt(password) - if err != nil { - return err - } - - cli := client.NewClient(url, user, decrypted) - err = cli.Login() + cli := client.NewClient(url, user, password) + err := cli.Login() if err != nil { return err } diff --git a/src/csi/backend/plugin/oceanstor.go b/src/csi/backend/plugin/oceanstor.go index a4d452a5..3c740b14 100644 --- a/src/csi/backend/plugin/oceanstor.go +++ b/src/csi/backend/plugin/oceanstor.go @@ -8,7 +8,6 @@ import ( "github.com/Huawei/eSDK_K8S_Plugin/src/storage/oceanstor/client" "github.com/Huawei/eSDK_K8S_Plugin/src/utils" "github.com/Huawei/eSDK_K8S_Plugin/src/utils/log" - "github.com/Huawei/eSDK_K8S_Plugin/src/utils/pwd" ) const ( @@ -51,15 +50,10 @@ func (p *OceanstorPlugin) init(config map[string]interface{}, keepLogin bool) er return errors.New("product only support config: V3, V5, Dorado") } - decrypted, err := pwd.Decrypt(password) - if err != nil { - return err - } - vstoreName, _ := config["vstoreName"].(string) - cli := client.NewClient(urls, user, decrypted, vstoreName) - err = cli.Login() + cli := client.NewClient(urls, user, password, vstoreName) + err := cli.Login() if err != nil { return err } diff --git a/src/tools/passwdEncrypt/passwdEncrypt.go b/src/tools/passwdEncrypt/passwdEncrypt.go deleted file mode 100644 index 8a5221c3..00000000 --- a/src/tools/passwdEncrypt/passwdEncrypt.go +++ /dev/null @@ -1,35 +0,0 @@ -package main - -import ( - "fmt" - "os" - - "github.com/Huawei/eSDK_K8S_Plugin/src/utils/pwd" - "golang.org/x/crypto/ssh/terminal" -) - -func main() { - var plainText string - - if len(os.Args) >= 2 { - plainText = os.Args[1] - } else { - fmt.Print("Enter password: ") - input, err := terminal.ReadPassword(0) - if err != nil { - fmt.Printf("Input password error: %v", err) - os.Exit(1) - } - - plainText = string(input) - fmt.Println("") - } - - encrypted, err := pwd.Encrypt(plainText) - if err != nil { - fmt.Printf("Encrypt password error: %v", err) - os.Exit(1) - } - - fmt.Println("Encrypted password:", encrypted) -} diff --git a/src/utils/pwd/pwd.go b/src/utils/pwd/pwd.go deleted file mode 100644 index bd33d681..00000000 --- a/src/utils/pwd/pwd.go +++ /dev/null @@ -1,53 +0,0 @@ -package pwd - -import ( - "crypto/aes" - "crypto/cipher" - "encoding/hex" -) - -var ( - commonIV = []byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f} - keyText = []byte("********************************") -) - -//加密 -func Encrypt(password string) (string, error) { - plaintext := []byte(password) - - // 创建加密算法aes - c, err := aes.NewCipher(keyText) - if err != nil { - return "", err - } - - ciphertext := make([]byte, len(plaintext)) - - //加密字符串 - cfb := cipher.NewCFBEncrypter(c, commonIV) - cfb.XORKeyStream(ciphertext, plaintext) - - return hex.EncodeToString(ciphertext), nil -} - -//解密 -func Decrypt(code string) (string, error) { - ciphertext, err := hex.DecodeString(code) - if err != nil { - return "", err - } - - // 创建加密算法aes - c, err := aes.NewCipher(keyText) - if err != nil { - return "", err - } - - plaintextCopy := make([]byte, len(ciphertext)) - - // 解密字符串 - cfbdec := cipher.NewCFBDecrypter(c, commonIV) - cfbdec.XORKeyStream(plaintextCopy, ciphertext) - - return string(plaintextCopy), nil -}