-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
78 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package naclbox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package naclbox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package naclbox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package secret | ||
|
||
import "context" | ||
|
||
type SecretOption func(o *SecretOptions) | ||
|
||
type SecretOptions struct { | ||
Context context.Context | ||
} | ||
|
||
func NewSecretOptions(opts ...SecretOption) SecretOptions { | ||
options := SecretOptions{ | ||
Context: context.Background(), | ||
} | ||
|
||
for _, fn := range opts { | ||
fn(&options) | ||
} | ||
|
||
return options | ||
} | ||
|
||
type EncryptOption func(o *EncryptOptions) | ||
|
||
type EncryptOptions struct { | ||
Context context.Context | ||
} | ||
|
||
func NewEncryptOptions(opts ...EncryptOption) EncryptOptions { | ||
options := EncryptOptions{ | ||
Context: context.Background(), | ||
} | ||
|
||
for _, fn := range opts { | ||
fn(&options) | ||
} | ||
|
||
return options | ||
} | ||
|
||
type DecryptOption func(o *DecryptOptions) | ||
|
||
type DecryptOptions struct { | ||
Context context.Context | ||
} | ||
|
||
func NewDecryptOptions(opts ...DecryptOption) DecryptOptions { | ||
options := DecryptOptions{ | ||
Context: context.Background(), | ||
} | ||
|
||
for _, fn := range opts { | ||
fn(&options) | ||
} | ||
|
||
return options | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package secret | ||
|
||
type Secret interface { | ||
Options() SecretOptions | ||
Encrypt(bytes []byte, opts ...EncryptOption) ([]byte, error) | ||
Decrypt(bytes []byte, opts ...DecryptOption) ([]byte, error) | ||
String() string | ||
} |