Documentation ¶
Index ¶
- Constants
- type Key
- type KeyManager
- func (m *KeyManager) Decrypt(cipherText string, label []byte) ([]byte, error)
- func (m *KeyManager) Encrypt(plainText []byte, label []byte) (string, error)
- func (m *KeyManager) GenerateKey(bits int) error
- func (m *KeyManager) Load(privateFile string, publicFile string) error
- func (m *KeyManager) Save(privateFile string, publicFile string) error
- func (m *KeyManager) SetReader(reader Reader)
- func (m *KeyManager) SetWriter(writer Writer)
- func (m *KeyManager) Sign(plainText []byte) ([]byte, error)
- func (m *KeyManager) Verify(plainText []byte, signature []byte) error
- type PemKey
- type Reader
- type SSHKey
- type Writer
Constants ¶
View Source
const ( DEFAULT_KEY_BITS = 1024 // default key bits. ADVANTAGE_KEY_BITS = 2048 // advantage key bits )
View Source
const ( DEFAULT_PEM_PUBLICFILE = `public.pem` // 默认公钥名 DEFAULT_PEM_PRIVATEFILE = `private.pem` // 默认私钥名 )
View Source
const ( DEFAULT_SSH_PUBLICFILE = `id_rsa.pub` // 默认公钥名 DEFAULT_SSH_PRIVATEFILE = `id_rsa` // 默认私钥名 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KeyManager ¶
type KeyManager struct { Key // contains filtered or unexported fields }
func New ¶
func New() *KeyManager
func (*KeyManager) Decrypt ¶
func (m *KeyManager) Decrypt(cipherText string, label []byte) ([]byte, error)
解密
func (*KeyManager) Encrypt ¶
func (m *KeyManager) Encrypt(plainText []byte, label []byte) (string, error)
加密
func (*KeyManager) GenerateKey ¶
func (m *KeyManager) GenerateKey(bits int) error
生成私钥公钥 明文长度(bytes)小于等于密钥长度(bytes) - 11(bytes) rsa的生成长度是用比特计算
func (*KeyManager) SetReader ¶
func (m *KeyManager) SetReader(reader Reader)
func (*KeyManager) SetWriter ¶
func (m *KeyManager) SetWriter(writer Writer)
Click to show internal directories.
Click to hide internal directories.