note

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2021 License: Apache-2.0 Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base58Decode

func Base58Decode(input []byte) []byte

Base58Decode decodes Base58-encoded data

func Base58Encode

func Base58Encode(input []byte) []byte

Base58Encode encodes a byte array to Base58

func CheckDbFileExist

func CheckDbFileExist(userName string) bool

func DecryptString

func DecryptString(source []byte) string

DecryptString decodes `source` with gob.

func EncryptString

func EncryptString(source string) []byte

EncryptString encodes `source` with gob.

func FormatTimestamp

func FormatTimestamp(t int64) string

FormatTimestamp transform timestamp to formatted time string.

func GenKeyForUserWithPasswd

func GenKeyForUserWithPasswd(userName, passwd string)

func GetAppFolderPath

func GetAppFolderPath() string

func GetAppHome

func GetAppHome() string

GetAppHome ...

func GetAppName

func GetAppName() string

GetAppName ...

func GetDbBucketName

func GetDbBucketName() string

GetDbBucketName returns default bucket name for a notebook.

func GetDbFilePath

func GetDbFilePath(userName string) string

GetDbFilePath returns the notebook path for userName.

func GetDbHeadKey

func GetDbHeadKey() string

GetDbHeadKey ...

func GetDbTailKey

func GetDbTailKey() string

GetDbTailKey ...

func GetHeadDefaultContent

func GetHeadDefaultContent() string

GetHeadDefaultContent returns content for the first note generated by system.

func GetPrivateKeyName

func GetPrivateKeyName() string

GetPrivateKeyName ...

func GetPrivateKeyPath

func GetPrivateKeyPath(userName string) string

func GetPrvKey

func GetPrvKey(userName string) []byte

GetPrvKey returns userName's private key

func GetPubKey

func GetPubKey(userName string) []byte

GetPubKey returns userName's public key

func GetPubKeyName

func GetPubKeyName() string

GetPubKeyName ...

func GetPublicKeyPath

func GetPublicKeyPath(userName string) string

func GetTailDefaultContent

func GetTailDefaultContent() string

GetTailDefaultContent returns content for the last note generated by system.

func GetVersion

func GetVersion() string

GetVersion ...

func RSADecrypt

func RSADecrypt(encryptedSrc []byte, prvKey []byte) (res []byte, err error)

RSADecrypt decrypt encrypted data with private key.

func RSADecryptWithPwd

func RSADecryptWithPwd(src []byte, prvKey []byte, pwd string) (res []byte, err error)

RSADecryptWithPwd decrypt src with private key and password

func RSAEncrypt

func RSAEncrypt(src []byte, pubKey []byte) (res []byte, err error)

RSAEncrypt use publicKey to encrypt source data.

func RSAGenKey

func RSAGenKey(bits int) (pubKey, prvKey []byte, err error)

RSAGenKey generate rsa key pair.

func RSAGenKeyWithPwd

func RSAGenKeyWithPwd(bits int, pwd string) (pubKey, prvKey []byte, err error)

-------------------------------- RSAGenKeyWithPwd generate rsa pair key with specified password

func StringToBytes

func StringToBytes(str string) []byte

StringToBytes change str to bytes without malloc.

Types

type Data

type Data struct {
	NewData string
}

Data a helper for encoding and decoding.

type Note

type Note struct {
	ID        []byte
	PrevID    []byte
	NextID    []byte
	Content   []byte
	Timestamp int64
}

Note means a note in notebook

func DeserializeNote

func DeserializeNote(data []byte, prvKey []byte, pwd string) *Note

DeserializeNote decodes bytes to Note.

func GetHeadNote

func GetHeadNote() *Note

GetHeadNote returns a Note with default `headContent`

func GetTailNote

func GetTailNote() *Note

GetTailNote return a Note with default `tailContent`

func NewNote

func NewNote(content string) *Note

NewNote returns a `Note` object with `content` and `timestamp`

func (*Note) Serialize

func (n *Note) Serialize(pubKey []byte) []byte

Serialize encodes a Note to bytes.

func (*Note) SetID

func (n *Note) SetID(t time.Time)

设置当前日记的ID(t为创建时间的时间戳)

func (*Note) SimpleString

func (n *Note) SimpleString() string

func (*Note) String

func (n *Note) String() string

type NoteBook

type NoteBook struct {
	Head []byte
	Tail []byte
	DB   *bolt.DB
}

NoteBook represents a diary book that contains many diary notes.

func CreateNewNoteBook

func CreateNewNoteBook(userName, passwd string) *NoteBook

CreateNewNoteBook creates a NoteBook for userName.

func GetNoteBook

func GetNoteBook(userName string) *NoteBook

GetNoteBook return userName's NoteBook

func (*NoteBook) AddNote

func (b *NoteBook) AddNote(note *Note, userName string, pwd string)

AddNote add a Note to NoteBook.

func (*NoteBook) DeleteNotePrefix

func (b *NoteBook) DeleteNotePrefix(id []byte, userName, pwd string)

DeleteNotePrefix delete notes that match prefix of `id`.

type NoteIter

type NoteIter struct {
	CurKey []byte
	Db     *bolt.DB
	PubKey []byte
	PrvKey []byte
	Passwd string
}

func NewNoteIter

func NewNoteIter(curKey string, db *bolt.DB, userName, pwd string) *NoteIter

func (*NoteIter) Next

func (i *NoteIter) Next() *Note

func (*NoteIter) Prev

func (i *NoteIter) Prev() *Note

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL