File: contract.go

package info (click to toggle)
golang-github-viant-toolbox 0.33.2-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 1,280 kB
  • sloc: makefile: 16
file content (51 lines) | stat: -rw-r--r-- 746 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package kms

import "errors"

type Resource struct {
	URL       string
	Parameter string
	Data      []byte
}

type EncryptRequest struct {
	Key string
	*Resource
	TargetURL string
}

type EncryptResponse struct {
	EncryptedData []byte
	EncryptedText string
}

type DecryptRequest struct {
	Key string
	*Resource
}

type DecryptResponse struct {
	Data []byte
	Text string
}

func (r *EncryptRequest) Validate() error {
	if r.Key == "" {
		return errors.New("key was empty")
	}
	if r.Resource == nil {
		return errors.New("nothing to encrypt")
	}
	return nil
}

func (r *DecryptRequest) Validate() error {
	if r.Key == "" {
		return errors.New("key was empty")
	}
	if r.Resource == nil {
		return errors.New("nothing to decrypt")
	}
	return nil

}