English | 简体中文
- Go 1.13 or later.
If you use go mod
to manage your dependence, You can declare the dependency on AlibabaCloud DKMS SDK for Go in the
go.mod file:
require (
github.com/aliyun/alibabacloud-dkms-gcs-go-sdk v0.5.1
github.com/alibabacloud-go/tea v1.1.17
)
Or, Run the following command to get the remote code package:
$ go get -u github.com/aliyun/alibabacloud-dkms-gcs-go-sdk
package example
import (
"fmt"
"github.com/alibabacloud-go/tea/tea"
dedicatedkmsopenapi "github.com/aliyun/alibabacloud-dkms-gcs-go-sdk/openapi"
dedicatedkmsopenapiutil "github.com/aliyun/alibabacloud-dkms-gcs-go-sdk/openapi-util"
dedicatedkmssdk "github.com/aliyun/alibabacloud-dkms-gcs-go-sdk/sdk"
)
func main() {
config := &dedicatedkmsopenapi.Config{
Protocol: tea.String("https"),
ClientKeyContent: tea.String("<your client key content>"),
Password: tea.String("<your client key password>"),
Endpoint: tea.String("<your dkms instance service endpoint>"),
}
client, err := dedicatedkmssdk.NewClient(config)
if err != nil {
panic(err)
}
runtimeOptions := &dedicatedkmsopenapiutil.RuntimeOptions{
IgnoreSSL: tea.Bool(true),
}
advanceEncryptRequest := &dedicatedkmssdk.AdvanceEncryptRequest{
KeyId: tea.String("<your key id>"),
Plaintext: []byte("plaintext"),
}
advanceEncryptResponse, err := client.AdvanceEncryptWithOptions(advanceEncryptRequest, runtimeOptions)
if err != nil {
panic(err)
}
fmt.Println(advanceEncryptResponse)
}
Copyright (c) 2009-present, Alibaba Cloud All rights reserved.