# README

aws-sdk-go-v2-wrapper | KMS

Quick Usage

import (
	"context"

	"github.com/evalphobia/aws-sdk-go-v2-wrapper/config"
	"github.com/evalphobia/aws-sdk-go-v2-wrapper/kms"
)

func main() {
	svc, err := kms.New(config.Config{
		AccessKey: "<...>",
		SecretKey: "<...>",
	})
	if err != nil {
		panic(err)
	}

	ctx := context.Background()
	base64Text, err := svc.XEncryptString(ctx, "alias/my-key", "I love you!")
	if err != nil {
		panic(err)
	}

	plainText, err := svc.XDecryptString(ctx, base64Text)
	if err != nil {
		panic(err)
	}

	if plainText != "I love you!" {
		panic("'plainText' should be 'I love you!'")
	}
	// ...
}

X API

NameDescription
XDeleteKeydeletes the key using 'ScheduleKeyDeletion'.
XEncryptBytesencrypts the 'plainData' using the 'key' and returns 'encryptedData'.
XEncryptStringencrypts the 'plainText' using the 'key' and returns encrypted 'base64Text'.
XDecryptBytesdecrypts the 'encryptedData'.
XDecryptStringdecrypts the 'base64Text'.
XReEncryptBytesre-encrypts the 'encryptedData' using 'destinationKey'.
XReEncryptStringre-encrypts the 'base64Text' using 'destinationKey'.