Documentation
¶
Index ¶
- func DeserializeGob(a interface{}, bb []byte) error
- func DigiPrint(s string) string
- func GenSalt(size int) []byte
- func GenerateCert(org, hosts string, bits int) (key, cert []byte, err error)
- func Hash(bb []byte, h hash.Hash) []byte
- func Lfmt(n int) string
- func NewCommentReader(r io.Reader, char rune) io.Reader
- func SaltedHash256(data, salt []byte) (hash, outSalt []byte)
- func SaltedHash512(data, salt []byte) (hash, outSalt []byte)
- func SerializeGob(a interface{}) ([]byte, error)
- func Sha256(bb []byte) []byte
- func Sha512(bb []byte) []byte
- func StrFieldsQuoted(bQuotedOnly bool) func(r rune) bool
- func ToHex(bb []byte) string
- func WithCtxKVMap(ctx context.Context, m map[interface{}]interface{}) context.Context
- func YielderArr(data []interface{}) func() (interface{}, bool)
- type CallInfo
- type CommentReader
- type Params
- func (this Params) Env(k string) string
- func (this Params) For(prefix string, cb func(k, v string))
- func (this Params) Get(s, defval string) string
- func (this Params) GetFloat64(s string, defval float64) float64
- func (this Params) GetInt(s string, defval int) int
- func (this *Params) Merge(a *Params)
- type PrivKey
- func (this *PrivKey) Decrypt(bb []byte) ([]byte, error)
- func (this *PrivKey) Marshal() []byte
- func (this *PrivKey) MarshalPem() []byte
- func (this *PrivKey) PubKey() *PubKey
- func (mypriv *PrivKey) Sign(bb []byte) (signature []byte, err error)
- func (mypriv *PrivKey) SignMessage(bb []byte) (msg *SignedMessage, err error)
- func (mypriv *PrivKey) SignMessageAndMarshal(bb []byte) ([]byte, error)
- type PubKey
- func (hisPubK *PubKey) DigiPrint() string
- func (this *PubKey) Encrypt(bb []byte) ([]byte, error)
- func (this *PubKey) Marshal() (bbPub []byte, err error)
- func (this *PubKey) MarshalPem() ([]byte, error)
- func (hisPubK *PubKey) Verify(msg, signature []byte) error
- func (hisPubK *PubKey) VerifyMessage(msg *SignedMessage) (err error)
- func (hisPubK *PubKey) VerifyMessageRaw(bb []byte) (msg []byte, err error)
- type SignedMessage
- type Stack
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeserializeGob ¶
func GenerateCert ¶
comma separted hosts / IP
func SaltedHash256 ¶
func SaltedHash512 ¶
func SerializeGob ¶
func StrFieldsQuoted ¶
func WithCtxKVMap ¶
func YielderArr ¶
func YielderArr(data []interface{}) func() (interface{}, bool)
Types ¶
type CallInfo ¶
type CallInfo struct {
// contains filtered or unexported fields
}
callInfo bundles the info about the call environment when a logging statement occured.
func RetrieveCallInfo ¶
func (*CallInfo) ShortFormat ¶
shortFormat returns a string representation in a short variant.
func (*CallInfo) VerboseFormat ¶
verboseFormat returns a string representation in a more verbose variant.
type CommentReader ¶
type CommentReader struct {
CommentChar rune
// contains filtered or unexported fields
}
type Params ¶
type Params struct {
// contains filtered or unexported fields
}
func ReadPropertyFile ¶
func ReadPropertyParams ¶
key / value separated by '='
type PrivKey ¶
type PrivKey rsa.PrivateKey
Example ¶
package main
import (
"fmt"
"github.com/noypi/util"
)
func main() {
// sender's keys
privkSender, _ := util.GenPrivKey(2048)
pubkSender := privkSender.PubKey()
// receiver's keys
privkRecvr, _ := util.GenPrivKey(2048)
pubkRecvr := privkRecvr.PubKey()
const message = "hello youtube"
// encrypt message
bbCipher, _ := pubkRecvr.Encrypt([]byte(message))
signatureSender, _ := privkSender.Sign(bbCipher)
// sending [cipher, signature]
// verify / decrypt message
bbPlain, _ := privkRecvr.Decrypt(bbCipher)
bValid := (nil == pubkSender.Verify(bbCipher, signatureSender))
if bValid {
fmt.Println(string(bbPlain))
}
}
Output: hello youtube
func GenPrivKey ¶
func (*PrivKey) MarshalPem ¶
func (*PrivKey) SignMessage ¶
func (mypriv *PrivKey) SignMessage(bb []byte) (msg *SignedMessage, err error)
type PubKey ¶
func ParsePublickey ¶
func ParsePublickeyPem ¶
func (*PubKey) MarshalPem ¶
func (*PubKey) VerifyMessage ¶
func (hisPubK *PubKey) VerifyMessage(msg *SignedMessage) (err error)
type SignedMessage ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.