id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
139,800 | davecheney/gpio | gpio_linux.go | Mode | func (p *pin) Mode() Mode {
var mode string
mode, p.err = readFile(p.modePath)
return Mode(mode)
} | go | func (p *pin) Mode() Mode {
var mode string
mode, p.err = readFile(p.modePath)
return Mode(mode)
} | [
"func",
"(",
"p",
"*",
"pin",
")",
"Mode",
"(",
")",
"Mode",
"{",
"var",
"mode",
"string",
"\n",
"mode",
",",
"p",
".",
"err",
"=",
"readFile",
"(",
"p",
".",
"modePath",
")",
"\n",
"return",
"Mode",
"(",
"mode",
")",
"\n",
"}"
] | // Mode retrieves the current mode of the pin. | [
"Mode",
"retrieves",
"the",
"current",
"mode",
"of",
"the",
"pin",
"."
] | a6de66e7e47065fca1a55c62c3f3cab3144694e6 | https://github.com/davecheney/gpio/blob/a6de66e7e47065fca1a55c62c3f3cab3144694e6/gpio_linux.go#L156-L160 |
139,801 | davecheney/gpio | gpio_linux.go | SetMode | func (p *pin) SetMode(mode Mode) {
p.err = p.setMode(mode)
} | go | func (p *pin) SetMode(mode Mode) {
p.err = p.setMode(mode)
} | [
"func",
"(",
"p",
"*",
"pin",
")",
"SetMode",
"(",
"mode",
"Mode",
")",
"{",
"p",
".",
"err",
"=",
"p",
".",
"setMode",
"(",
"mode",
")",
"\n",
"}"
] | // SetMode sets the mode of the pin. | [
"SetMode",
"sets",
"the",
"mode",
"of",
"the",
"pin",
"."
] | a6de66e7e47065fca1a55c62c3f3cab3144694e6 | https://github.com/davecheney/gpio/blob/a6de66e7e47065fca1a55c62c3f3cab3144694e6/gpio_linux.go#L163-L165 |
139,802 | davecheney/gpio | gpio_linux.go | Set | func (p *pin) Set() {
_, p.err = p.valueFile.Write(bytesSet)
} | go | func (p *pin) Set() {
_, p.err = p.valueFile.Write(bytesSet)
} | [
"func",
"(",
"p",
"*",
"pin",
")",
"Set",
"(",
")",
"{",
"_",
",",
"p",
".",
"err",
"=",
"p",
".",
"valueFile",
".",
"Write",
"(",
"bytesSet",
")",
"\n",
"}"
] | // Set sets the pin level high. | [
"Set",
"sets",
"the",
"pin",
"level",
"high",
"."
] | a6de66e7e47065fca1a55c62c3f3cab3144694e6 | https://github.com/davecheney/gpio/blob/a6de66e7e47065fca1a55c62c3f3cab3144694e6/gpio_linux.go#L182-L184 |
139,803 | davecheney/gpio | gpio_linux.go | Clear | func (p *pin) Clear() {
_, p.err = p.valueFile.Write(bytesClear)
} | go | func (p *pin) Clear() {
_, p.err = p.valueFile.Write(bytesClear)
} | [
"func",
"(",
"p",
"*",
"pin",
")",
"Clear",
"(",
")",
"{",
"_",
",",
"p",
".",
"err",
"=",
"p",
".",
"valueFile",
".",
"Write",
"(",
"bytesClear",
")",
"\n",
"}"
] | // Clear sets the pin level low. | [
"Clear",
"sets",
"the",
"pin",
"level",
"low",
"."
] | a6de66e7e47065fca1a55c62c3f3cab3144694e6 | https://github.com/davecheney/gpio/blob/a6de66e7e47065fca1a55c62c3f3cab3144694e6/gpio_linux.go#L187-L189 |
139,804 | davecheney/gpio | gpio_linux.go | Get | func (p *pin) Get() bool {
bytes := make([]byte, 1)
_, p.err = p.valueFile.ReadAt(bytes, 0)
return bytes[0] == bytesSet[0]
} | go | func (p *pin) Get() bool {
bytes := make([]byte, 1)
_, p.err = p.valueFile.ReadAt(bytes, 0)
return bytes[0] == bytesSet[0]
} | [
"func",
"(",
"p",
"*",
"pin",
")",
"Get",
"(",
")",
"bool",
"{",
"bytes",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"1",
")",
"\n",
"_",
",",
"p",
".",
"err",
"=",
"p",
".",
"valueFile",
".",
"ReadAt",
"(",
"bytes",
",",
"0",
")",
"\n",
"... | // Get retrieves the current pin level. | [
"Get",
"retrieves",
"the",
"current",
"pin",
"level",
"."
] | a6de66e7e47065fca1a55c62c3f3cab3144694e6 | https://github.com/davecheney/gpio/blob/a6de66e7e47065fca1a55c62c3f3cab3144694e6/gpio_linux.go#L192-L196 |
139,805 | davecheney/gpio | gpio_linux.go | BeginWatch | func (p *pin) BeginWatch(edge Edge, callback IRQEvent) error {
p.SetMode(ModeInput)
if err := write([]byte(edge), p.edgePath); err != nil {
return err
}
var event syscall.EpollEvent
event.Events = syscall.EPOLLIN | (syscall.EPOLLET & 0xffffffff) | syscall.EPOLLPRI
fd := int(p.valueFile.Fd())
p.callback = ca... | go | func (p *pin) BeginWatch(edge Edge, callback IRQEvent) error {
p.SetMode(ModeInput)
if err := write([]byte(edge), p.edgePath); err != nil {
return err
}
var event syscall.EpollEvent
event.Events = syscall.EPOLLIN | (syscall.EPOLLET & 0xffffffff) | syscall.EPOLLPRI
fd := int(p.valueFile.Fd())
p.callback = ca... | [
"func",
"(",
"p",
"*",
"pin",
")",
"BeginWatch",
"(",
"edge",
"Edge",
",",
"callback",
"IRQEvent",
")",
"error",
"{",
"p",
".",
"SetMode",
"(",
"ModeInput",
")",
"\n",
"if",
"err",
":=",
"write",
"(",
"[",
"]",
"byte",
"(",
"edge",
")",
",",
"p",... | // Watch waits for the edge level to be triggered and then calls the callback
// Watch sets the pin mode to input on your behalf, then establishes the interrupt on
// the edge provided | [
"Watch",
"waits",
"for",
"the",
"edge",
"level",
"to",
"be",
"triggered",
"and",
"then",
"calls",
"the",
"callback",
"Watch",
"sets",
"the",
"pin",
"mode",
"to",
"input",
"on",
"your",
"behalf",
"then",
"establishes",
"the",
"interrupt",
"on",
"the",
"edge... | a6de66e7e47065fca1a55c62c3f3cab3144694e6 | https://github.com/davecheney/gpio/blob/a6de66e7e47065fca1a55c62c3f3cab3144694e6/gpio_linux.go#L202-L228 |
139,806 | davecheney/gpio | gpio_linux.go | EndWatch | func (p *pin) EndWatch() error {
fd := int(p.valueFile.Fd())
if err := syscall.EpollCtl(epollFD, syscall.EPOLL_CTL_DEL, fd, nil); err != nil {
return err
}
if err := syscall.SetNonblock(fd, false); err != nil {
return err
}
delete(watchEventCallbacks, fd)
return nil
} | go | func (p *pin) EndWatch() error {
fd := int(p.valueFile.Fd())
if err := syscall.EpollCtl(epollFD, syscall.EPOLL_CTL_DEL, fd, nil); err != nil {
return err
}
if err := syscall.SetNonblock(fd, false); err != nil {
return err
}
delete(watchEventCallbacks, fd)
return nil
} | [
"func",
"(",
"p",
"*",
"pin",
")",
"EndWatch",
"(",
")",
"error",
"{",
"fd",
":=",
"int",
"(",
"p",
".",
"valueFile",
".",
"Fd",
"(",
")",
")",
"\n\n",
"if",
"err",
":=",
"syscall",
".",
"EpollCtl",
"(",
"epollFD",
",",
"syscall",
".",
"EPOLL_CTL... | // EndWatch stops watching the pin | [
"EndWatch",
"stops",
"watching",
"the",
"pin"
] | a6de66e7e47065fca1a55c62c3f3cab3144694e6 | https://github.com/davecheney/gpio/blob/a6de66e7e47065fca1a55c62c3f3cab3144694e6/gpio_linux.go#L231-L247 |
139,807 | tobischo/gokeepasslib | encoder.go | Encode | func (e *Encoder) Encode(db *Database) error {
// Calculate transformed key to make HMAC and encrypt
transformedKey, err := db.getTransformedKey()
if err != nil {
return err
}
// Write header then hashes before decode content (necessary to update HeaderHash)
// db.Header writeTo will change its hash
if err = ... | go | func (e *Encoder) Encode(db *Database) error {
// Calculate transformed key to make HMAC and encrypt
transformedKey, err := db.getTransformedKey()
if err != nil {
return err
}
// Write header then hashes before decode content (necessary to update HeaderHash)
// db.Header writeTo will change its hash
if err = ... | [
"func",
"(",
"e",
"*",
"Encoder",
")",
"Encode",
"(",
"db",
"*",
"Database",
")",
"error",
"{",
"// Calculate transformed key to make HMAC and encrypt",
"transformedKey",
",",
"err",
":=",
"db",
".",
"getTransformedKey",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil... | // Encode writes db to e's internal writer | [
"Encode",
"writes",
"db",
"to",
"e",
"s",
"internal",
"writer"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/encoder.go#L25-L80 |
139,808 | tobischo/gokeepasslib | credentials.go | NewPasswordCredentials | func NewPasswordCredentials(password string) *DBCredentials {
hashedpw := sha256.Sum256([]byte(password))
return &DBCredentials{Passphrase: hashedpw[:]}
} | go | func NewPasswordCredentials(password string) *DBCredentials {
hashedpw := sha256.Sum256([]byte(password))
return &DBCredentials{Passphrase: hashedpw[:]}
} | [
"func",
"NewPasswordCredentials",
"(",
"password",
"string",
")",
"*",
"DBCredentials",
"{",
"hashedpw",
":=",
"sha256",
".",
"Sum256",
"(",
"[",
"]",
"byte",
"(",
"password",
")",
")",
"\n",
"return",
"&",
"DBCredentials",
"{",
"Passphrase",
":",
"hashedpw"... | // NewPasswordCredentials builds a new DBCredentials from a Password string | [
"NewPasswordCredentials",
"builds",
"a",
"new",
"DBCredentials",
"from",
"a",
"Password",
"string"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/credentials.go#L130-L133 |
139,809 | tobischo/gokeepasslib | credentials.go | ParseKeyFile | func ParseKeyFile(location string) ([]byte, error) {
r, err := regexp.Compile(`<Data>(.+)</Data>`)
if err != nil {
return nil, err
}
file, err := os.Open(location)
if err != nil {
return nil, err
}
var data []byte
if data, err = ioutil.ReadAll(file); err != nil {
return nil, err
}
if r.Match(data) { //I... | go | func ParseKeyFile(location string) ([]byte, error) {
r, err := regexp.Compile(`<Data>(.+)</Data>`)
if err != nil {
return nil, err
}
file, err := os.Open(location)
if err != nil {
return nil, err
}
var data []byte
if data, err = ioutil.ReadAll(file); err != nil {
return nil, err
}
if r.Match(data) { //I... | [
"func",
"ParseKeyFile",
"(",
"location",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"r",
",",
"err",
":=",
"regexp",
".",
"Compile",
"(",
"`<Data>(.+)</Data>`",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",... | // ParseKeyFile returns the hashed key from a key file at the path specified by location, parsing xml if needed | [
"ParseKeyFile",
"returns",
"the",
"hashed",
"key",
"from",
"a",
"key",
"file",
"at",
"the",
"path",
"specified",
"by",
"location",
"parsing",
"xml",
"if",
"needed"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/credentials.go#L136-L158 |
139,810 | tobischo/gokeepasslib | credentials.go | NewKeyCredentials | func NewKeyCredentials(location string) (*DBCredentials, error) {
key, err := ParseKeyFile(location)
if err != nil {
return nil, err
}
return &DBCredentials{Key: key}, nil
} | go | func NewKeyCredentials(location string) (*DBCredentials, error) {
key, err := ParseKeyFile(location)
if err != nil {
return nil, err
}
return &DBCredentials{Key: key}, nil
} | [
"func",
"NewKeyCredentials",
"(",
"location",
"string",
")",
"(",
"*",
"DBCredentials",
",",
"error",
")",
"{",
"key",
",",
"err",
":=",
"ParseKeyFile",
"(",
"location",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
... | // NewKeyCredentials builds a new DBCredentials from a key file at the path specified by location | [
"NewKeyCredentials",
"builds",
"a",
"new",
"DBCredentials",
"from",
"a",
"key",
"file",
"at",
"the",
"path",
"specified",
"by",
"location"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/credentials.go#L161-L168 |
139,811 | tobischo/gokeepasslib | credentials.go | NewPasswordAndKeyCredentials | func NewPasswordAndKeyCredentials(password, location string) (*DBCredentials, error) {
key, err := ParseKeyFile(location)
if err != nil {
return nil, err
}
hashedpw := sha256.Sum256([]byte(password))
return &DBCredentials{
Passphrase: hashedpw[:],
Key: key,
}, nil
} | go | func NewPasswordAndKeyCredentials(password, location string) (*DBCredentials, error) {
key, err := ParseKeyFile(location)
if err != nil {
return nil, err
}
hashedpw := sha256.Sum256([]byte(password))
return &DBCredentials{
Passphrase: hashedpw[:],
Key: key,
}, nil
} | [
"func",
"NewPasswordAndKeyCredentials",
"(",
"password",
",",
"location",
"string",
")",
"(",
"*",
"DBCredentials",
",",
"error",
")",
"{",
"key",
",",
"err",
":=",
"ParseKeyFile",
"(",
"location",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",... | // NewPasswordAndKeyCredentials builds a new DBCredentials from a password and the key file at the path specified by location | [
"NewPasswordAndKeyCredentials",
"builds",
"a",
"new",
"DBCredentials",
"from",
"a",
"password",
"and",
"the",
"key",
"file",
"at",
"the",
"path",
"specified",
"by",
"location"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/credentials.go#L171-L183 |
139,812 | tobischo/gokeepasslib | xml.go | NewMetaData | func NewMetaData() *MetaData {
now := w.Now()
return &MetaData{
MasterKeyChanged: &now,
MasterKeyChangeRec: -1,
MasterKeyChangeForce: -1,
HistoryMaxItems: 10,
HistoryMaxSize: 6291456, // 6 MB
MaintenanceHistoryDays: 365,
}
} | go | func NewMetaData() *MetaData {
now := w.Now()
return &MetaData{
MasterKeyChanged: &now,
MasterKeyChangeRec: -1,
MasterKeyChangeForce: -1,
HistoryMaxItems: 10,
HistoryMaxSize: 6291456, // 6 MB
MaintenanceHistoryDays: 365,
}
} | [
"func",
"NewMetaData",
"(",
")",
"*",
"MetaData",
"{",
"now",
":=",
"w",
".",
"Now",
"(",
")",
"\n\n",
"return",
"&",
"MetaData",
"{",
"MasterKeyChanged",
":",
"&",
"now",
",",
"MasterKeyChangeRec",
":",
"-",
"1",
",",
"MasterKeyChangeForce",
":",
"-",
... | // NewMetaData creates a MetaData struct with some defaults set | [
"NewMetaData",
"creates",
"a",
"MetaData",
"struct",
"with",
"some",
"defaults",
"set"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/xml.go#L149-L160 |
139,813 | tobischo/gokeepasslib | xml.go | NewRootData | func NewRootData() *RootData {
root := new(RootData)
group := NewGroup()
group.Name = "NewDatabase"
entry := NewEntry()
entry.Values = append(entry.Values, ValueData{Key: "Title", Value: V{Content: "Sample Entry"}})
group.Entries = append(group.Entries, entry)
root.Groups = append(root.Groups, group)
return roo... | go | func NewRootData() *RootData {
root := new(RootData)
group := NewGroup()
group.Name = "NewDatabase"
entry := NewEntry()
entry.Values = append(entry.Values, ValueData{Key: "Title", Value: V{Content: "Sample Entry"}})
group.Entries = append(group.Entries, entry)
root.Groups = append(root.Groups, group)
return roo... | [
"func",
"NewRootData",
"(",
")",
"*",
"RootData",
"{",
"root",
":=",
"new",
"(",
"RootData",
")",
"\n",
"group",
":=",
"NewGroup",
"(",
")",
"\n",
"group",
".",
"Name",
"=",
"\"",
"\"",
"\n",
"entry",
":=",
"NewEntry",
"(",
")",
"\n",
"entry",
".",... | // NewRootData returns a RootData struct with good defaults | [
"NewRootData",
"returns",
"a",
"RootData",
"struct",
"with",
"good",
"defaults"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/xml.go#L163-L172 |
139,814 | tobischo/gokeepasslib | xml.go | NewGroup | func NewGroup() Group {
return Group{
EnableAutoType: w.BoolWrapper(true),
EnableSearching: w.BoolWrapper(true),
Times: NewTimeData(),
UUID: NewUUID(),
}
} | go | func NewGroup() Group {
return Group{
EnableAutoType: w.BoolWrapper(true),
EnableSearching: w.BoolWrapper(true),
Times: NewTimeData(),
UUID: NewUUID(),
}
} | [
"func",
"NewGroup",
"(",
")",
"Group",
"{",
"return",
"Group",
"{",
"EnableAutoType",
":",
"w",
".",
"BoolWrapper",
"(",
"true",
")",
",",
"EnableSearching",
":",
"w",
".",
"BoolWrapper",
"(",
"true",
")",
",",
"Times",
":",
"NewTimeData",
"(",
")",
",... | // NewGroup returns a new group with time data and uuid set | [
"NewGroup",
"returns",
"a",
"new",
"group",
"with",
"time",
"data",
"and",
"uuid",
"set"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/xml.go#L182-L189 |
139,815 | tobischo/gokeepasslib | xml.go | NewEntry | func NewEntry() Entry {
e := Entry{}
e.Times = NewTimeData()
e.UUID = NewUUID()
return e
} | go | func NewEntry() Entry {
e := Entry{}
e.Times = NewTimeData()
e.UUID = NewUUID()
return e
} | [
"func",
"NewEntry",
"(",
")",
"Entry",
"{",
"e",
":=",
"Entry",
"{",
"}",
"\n",
"e",
".",
"Times",
"=",
"NewTimeData",
"(",
")",
"\n",
"e",
".",
"UUID",
"=",
"NewUUID",
"(",
")",
"\n",
"return",
"e",
"\n",
"}"
] | // NewEntry return a new entry with time data and uuid set | [
"NewEntry",
"return",
"a",
"new",
"entry",
"with",
"time",
"data",
"and",
"uuid",
"set"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/xml.go#L205-L210 |
139,816 | tobischo/gokeepasslib | xml.go | MarshalText | func (u UUID) MarshalText() ([]byte, error) {
text := make([]byte, 24)
base64.StdEncoding.Encode(text, u[:])
return text, nil
} | go | func (u UUID) MarshalText() ([]byte, error) {
text := make([]byte, 24)
base64.StdEncoding.Encode(text, u[:])
return text, nil
} | [
"func",
"(",
"u",
"UUID",
")",
"MarshalText",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"text",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"24",
")",
"\n",
"base64",
".",
"StdEncoding",
".",
"Encode",
"(",
"text",
",",
"u",
"[",
... | // MarshalText is a marshaler method to encode uuid content as base 64 and return it | [
"MarshalText",
"is",
"a",
"marshaler",
"method",
"to",
"encode",
"uuid",
"content",
"as",
"base",
"64",
"and",
"return",
"it"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/xml.go#L213-L217 |
139,817 | tobischo/gokeepasslib | xml.go | UnmarshalText | func (u *UUID) UnmarshalText(text []byte) error {
id := make([]byte, base64.StdEncoding.DecodedLen(len(text)))
length, err := base64.StdEncoding.Decode(id, text)
if err != nil {
return err
}
if length != 16 {
return ErrInvalidUUIDLength
}
copy((*u)[:], id[:16])
return nil
} | go | func (u *UUID) UnmarshalText(text []byte) error {
id := make([]byte, base64.StdEncoding.DecodedLen(len(text)))
length, err := base64.StdEncoding.Decode(id, text)
if err != nil {
return err
}
if length != 16 {
return ErrInvalidUUIDLength
}
copy((*u)[:], id[:16])
return nil
} | [
"func",
"(",
"u",
"*",
"UUID",
")",
"UnmarshalText",
"(",
"text",
"[",
"]",
"byte",
")",
"error",
"{",
"id",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"base64",
".",
"StdEncoding",
".",
"DecodedLen",
"(",
"len",
"(",
"text",
")",
")",
")",
"\n",
... | // UnmarshalText unmarshals a byte slice into a UUID by decoding the given data from base64 | [
"UnmarshalText",
"unmarshals",
"a",
"byte",
"slice",
"into",
"a",
"UUID",
"by",
"decoding",
"the",
"given",
"data",
"from",
"base64"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/xml.go#L220-L231 |
139,818 | tobischo/gokeepasslib | xml.go | Compare | func (u UUID) Compare(c UUID) bool {
for i, v := range c {
if u[i] != v {
return false
}
}
return true
} | go | func (u UUID) Compare(c UUID) bool {
for i, v := range c {
if u[i] != v {
return false
}
}
return true
} | [
"func",
"(",
"u",
"UUID",
")",
"Compare",
"(",
"c",
"UUID",
")",
"bool",
"{",
"for",
"i",
",",
"v",
":=",
"range",
"c",
"{",
"if",
"u",
"[",
"i",
"]",
"!=",
"v",
"{",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}... | // Compare allowes to check whether two instance of UUID are equal in value.
// This is used for searching a uuid | [
"Compare",
"allowes",
"to",
"check",
"whether",
"two",
"instance",
"of",
"UUID",
"are",
"equal",
"in",
"value",
".",
"This",
"is",
"used",
"for",
"searching",
"a",
"uuid"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/xml.go#L235-L242 |
139,819 | tobischo/gokeepasslib | xml.go | Get | func (e *Entry) Get(key string) *ValueData {
for i := range e.Values {
if e.Values[i].Key == key {
return &e.Values[i]
}
}
return nil
} | go | func (e *Entry) Get(key string) *ValueData {
for i := range e.Values {
if e.Values[i].Key == key {
return &e.Values[i]
}
}
return nil
} | [
"func",
"(",
"e",
"*",
"Entry",
")",
"Get",
"(",
"key",
"string",
")",
"*",
"ValueData",
"{",
"for",
"i",
":=",
"range",
"e",
".",
"Values",
"{",
"if",
"e",
".",
"Values",
"[",
"i",
"]",
".",
"Key",
"==",
"key",
"{",
"return",
"&",
"e",
".",
... | // Get returns the value in e corresponding with key k, or an empty string otherwise | [
"Get",
"returns",
"the",
"value",
"in",
"e",
"corresponding",
"with",
"key",
"k",
"or",
"an",
"empty",
"string",
"otherwise"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/xml.go#L245-L252 |
139,820 | tobischo/gokeepasslib | xml.go | GetContent | func (e *Entry) GetContent(key string) string {
val := e.Get(key)
if val == nil {
return ""
}
return val.Value.Content
} | go | func (e *Entry) GetContent(key string) string {
val := e.Get(key)
if val == nil {
return ""
}
return val.Value.Content
} | [
"func",
"(",
"e",
"*",
"Entry",
")",
"GetContent",
"(",
"key",
"string",
")",
"string",
"{",
"val",
":=",
"e",
".",
"Get",
"(",
"key",
")",
"\n",
"if",
"val",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"val",
".",
"Value... | // GetContent returns the content of the value belonging to the given key in string form | [
"GetContent",
"returns",
"the",
"content",
"of",
"the",
"value",
"belonging",
"to",
"the",
"given",
"key",
"in",
"string",
"form"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/xml.go#L255-L261 |
139,821 | tobischo/gokeepasslib | xml.go | GetIndex | func (e *Entry) GetIndex(key string) int {
for i := range e.Values {
if e.Values[i].Key == key {
return i
}
}
return -1
} | go | func (e *Entry) GetIndex(key string) int {
for i := range e.Values {
if e.Values[i].Key == key {
return i
}
}
return -1
} | [
"func",
"(",
"e",
"*",
"Entry",
")",
"GetIndex",
"(",
"key",
"string",
")",
"int",
"{",
"for",
"i",
":=",
"range",
"e",
".",
"Values",
"{",
"if",
"e",
".",
"Values",
"[",
"i",
"]",
".",
"Key",
"==",
"key",
"{",
"return",
"i",
"\n",
"}",
"\n",... | // GetIndex returns the index of the Value belonging to the given key, or -1 if none is found | [
"GetIndex",
"returns",
"the",
"index",
"of",
"the",
"Value",
"belonging",
"to",
"the",
"given",
"key",
"or",
"-",
"1",
"if",
"none",
"is",
"found"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/xml.go#L264-L271 |
139,822 | tobischo/gokeepasslib | database.go | getTransformedKey | func (db *Database) getTransformedKey() ([]byte, error) {
if db.Credentials == nil {
return nil, ErrRequiredAttributeMissing("Credentials")
}
return db.Credentials.buildTransformedKey(db)
} | go | func (db *Database) getTransformedKey() ([]byte, error) {
if db.Credentials == nil {
return nil, ErrRequiredAttributeMissing("Credentials")
}
return db.Credentials.buildTransformedKey(db)
} | [
"func",
"(",
"db",
"*",
"Database",
")",
"getTransformedKey",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"db",
".",
"Credentials",
"==",
"nil",
"{",
"return",
"nil",
",",
"ErrRequiredAttributeMissing",
"(",
"\"",
"\"",
")",
"\n",
... | // getTransformedKey returns the transformed key Credentials | [
"getTransformedKey",
"returns",
"the",
"transformed",
"key",
"Credentials"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/database.go#L42-L47 |
139,823 | tobischo/gokeepasslib | database.go | GetEncrypterManager | func (db *Database) GetEncrypterManager(transformedKey []byte) (*EncrypterManager, error) {
return NewEncrypterManager(
buildMasterKey(db, transformedKey),
db.Header.FileHeaders.EncryptionIV,
)
} | go | func (db *Database) GetEncrypterManager(transformedKey []byte) (*EncrypterManager, error) {
return NewEncrypterManager(
buildMasterKey(db, transformedKey),
db.Header.FileHeaders.EncryptionIV,
)
} | [
"func",
"(",
"db",
"*",
"Database",
")",
"GetEncrypterManager",
"(",
"transformedKey",
"[",
"]",
"byte",
")",
"(",
"*",
"EncrypterManager",
",",
"error",
")",
"{",
"return",
"NewEncrypterManager",
"(",
"buildMasterKey",
"(",
"db",
",",
"transformedKey",
")",
... | // GetEncrypterManager returns an EncryptManager based on the master key and EncryptionIV, or nil if the type is unsupported | [
"GetEncrypterManager",
"returns",
"an",
"EncryptManager",
"based",
"on",
"the",
"master",
"key",
"and",
"EncryptionIV",
"or",
"nil",
"if",
"the",
"type",
"is",
"unsupported"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/database.go#L50-L55 |
139,824 | tobischo/gokeepasslib | database.go | GetStreamManager | func (db *Database) GetStreamManager() (*StreamManager, error) {
if db.Header.FileHeaders != nil {
if db.Header.IsKdbx4() {
return NewStreamManager(
db.Content.InnerHeader.InnerRandomStreamID,
db.Content.InnerHeader.InnerRandomStreamKey,
)
}
return NewStreamManager(
db.Header.FileHeaders.InnerR... | go | func (db *Database) GetStreamManager() (*StreamManager, error) {
if db.Header.FileHeaders != nil {
if db.Header.IsKdbx4() {
return NewStreamManager(
db.Content.InnerHeader.InnerRandomStreamID,
db.Content.InnerHeader.InnerRandomStreamKey,
)
}
return NewStreamManager(
db.Header.FileHeaders.InnerR... | [
"func",
"(",
"db",
"*",
"Database",
")",
"GetStreamManager",
"(",
")",
"(",
"*",
"StreamManager",
",",
"error",
")",
"{",
"if",
"db",
".",
"Header",
".",
"FileHeaders",
"!=",
"nil",
"{",
"if",
"db",
".",
"Header",
".",
"IsKdbx4",
"(",
")",
"{",
"re... | // GetStreamManager returns a StreamManager based on the db headers, or nil if the type is unsupported
// Can be used to lock only certain entries instead of calling | [
"GetStreamManager",
"returns",
"a",
"StreamManager",
"based",
"on",
"the",
"db",
"headers",
"or",
"nil",
"if",
"the",
"type",
"is",
"unsupported",
"Can",
"be",
"used",
"to",
"lock",
"only",
"certain",
"entries",
"instead",
"of",
"calling"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/database.go#L59-L74 |
139,825 | tobischo/gokeepasslib | binary.go | Find | func (bs Binaries) Find(id int) *Binary {
for i := range bs {
if bs[i].ID == id {
return &bs[i]
}
}
return nil
} | go | func (bs Binaries) Find(id int) *Binary {
for i := range bs {
if bs[i].ID == id {
return &bs[i]
}
}
return nil
} | [
"func",
"(",
"bs",
"Binaries",
")",
"Find",
"(",
"id",
"int",
")",
"*",
"Binary",
"{",
"for",
"i",
":=",
"range",
"bs",
"{",
"if",
"bs",
"[",
"i",
"]",
".",
"ID",
"==",
"id",
"{",
"return",
"&",
"bs",
"[",
"i",
"]",
"\n",
"}",
"\n",
"}",
... | // Find returns a reference to a binary with the same ID as id, or nil if none if found | [
"Find",
"returns",
"a",
"reference",
"to",
"a",
"binary",
"with",
"the",
"same",
"ID",
"as",
"id",
"or",
"nil",
"if",
"none",
"if",
"found"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/binary.go#L36-L43 |
139,826 | tobischo/gokeepasslib | binary.go | Find | func (br *BinaryReference) Find(db *Database) *Binary {
if db.Header.IsKdbx4() {
return db.Content.InnerHeader.Binaries.Find(br.Value.ID)
}
return db.Content.Meta.Binaries.Find(br.Value.ID)
} | go | func (br *BinaryReference) Find(db *Database) *Binary {
if db.Header.IsKdbx4() {
return db.Content.InnerHeader.Binaries.Find(br.Value.ID)
}
return db.Content.Meta.Binaries.Find(br.Value.ID)
} | [
"func",
"(",
"br",
"*",
"BinaryReference",
")",
"Find",
"(",
"db",
"*",
"Database",
")",
"*",
"Binary",
"{",
"if",
"db",
".",
"Header",
".",
"IsKdbx4",
"(",
")",
"{",
"return",
"db",
".",
"Content",
".",
"InnerHeader",
".",
"Binaries",
".",
"Find",
... | // Find returns a reference to a binary in the database db with the same id as br, or nil if none is found | [
"Find",
"returns",
"a",
"reference",
"to",
"a",
"binary",
"in",
"the",
"database",
"db",
"with",
"the",
"same",
"id",
"as",
"br",
"or",
"nil",
"if",
"none",
"is",
"found"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/binary.go#L46-L51 |
139,827 | tobischo/gokeepasslib | binary.go | Add | func (bs *Binaries) Add(c []byte) *Binary {
binary := Binary{
Compressed: wrappers.BoolWrapper(true),
}
if len(*bs) == 0 {
binary.ID = 0
} else {
binary.ID = (*bs)[len(*bs)-1].ID + 1
}
binary.SetContent(c)
*bs = append(*bs, binary)
return &(*bs)[len(*bs)-1]
} | go | func (bs *Binaries) Add(c []byte) *Binary {
binary := Binary{
Compressed: wrappers.BoolWrapper(true),
}
if len(*bs) == 0 {
binary.ID = 0
} else {
binary.ID = (*bs)[len(*bs)-1].ID + 1
}
binary.SetContent(c)
*bs = append(*bs, binary)
return &(*bs)[len(*bs)-1]
} | [
"func",
"(",
"bs",
"*",
"Binaries",
")",
"Add",
"(",
"c",
"[",
"]",
"byte",
")",
"*",
"Binary",
"{",
"binary",
":=",
"Binary",
"{",
"Compressed",
":",
"wrappers",
".",
"BoolWrapper",
"(",
"true",
")",
",",
"}",
"\n",
"if",
"len",
"(",
"*",
"bs",
... | // Add appends binary data to the slice | [
"Add",
"appends",
"binary",
"data",
"to",
"the",
"slice"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/binary.go#L54-L66 |
139,828 | tobischo/gokeepasslib | binary.go | GetContent | func (b Binary) GetContent() (string, error) {
// Check for base64 content (KDBX 3.1), if it fail try with KDBX 4
decoded := make([]byte, base64.StdEncoding.DecodedLen(len(b.Content)))
_, err := base64.StdEncoding.Decode(decoded, b.Content)
if err != nil {
// KDBX 4 doesn't encode it
decoded = b.Content[:]
}
... | go | func (b Binary) GetContent() (string, error) {
// Check for base64 content (KDBX 3.1), if it fail try with KDBX 4
decoded := make([]byte, base64.StdEncoding.DecodedLen(len(b.Content)))
_, err := base64.StdEncoding.Decode(decoded, b.Content)
if err != nil {
// KDBX 4 doesn't encode it
decoded = b.Content[:]
}
... | [
"func",
"(",
"b",
"Binary",
")",
"GetContent",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"// Check for base64 content (KDBX 3.1), if it fail try with KDBX 4",
"decoded",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"base64",
".",
"StdEncoding",
".",
"Decoded... | // GetContent returns a string which is the plaintext content of a binary | [
"GetContent",
"returns",
"a",
"string",
"which",
"is",
"the",
"plaintext",
"content",
"of",
"a",
"binary"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/binary.go#L69-L91 |
139,829 | tobischo/gokeepasslib | binary.go | CreateReference | func (b Binary) CreateReference(f string) BinaryReference {
return NewBinaryReference(f, b.ID)
} | go | func (b Binary) CreateReference(f string) BinaryReference {
return NewBinaryReference(f, b.ID)
} | [
"func",
"(",
"b",
"Binary",
")",
"CreateReference",
"(",
"f",
"string",
")",
"BinaryReference",
"{",
"return",
"NewBinaryReference",
"(",
"f",
",",
"b",
".",
"ID",
")",
"\n",
"}"
] | // CreateReference creates a reference with the same id as b with filename f | [
"CreateReference",
"creates",
"a",
"reference",
"with",
"the",
"same",
"id",
"as",
"b",
"with",
"filename",
"f"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/binary.go#L112-L114 |
139,830 | tobischo/gokeepasslib | binary.go | NewBinaryReference | func NewBinaryReference(name string, id int) BinaryReference {
ref := BinaryReference{}
ref.Name = name
ref.Value.ID = id
return ref
} | go | func NewBinaryReference(name string, id int) BinaryReference {
ref := BinaryReference{}
ref.Name = name
ref.Value.ID = id
return ref
} | [
"func",
"NewBinaryReference",
"(",
"name",
"string",
",",
"id",
"int",
")",
"BinaryReference",
"{",
"ref",
":=",
"BinaryReference",
"{",
"}",
"\n",
"ref",
".",
"Name",
"=",
"name",
"\n",
"ref",
".",
"Value",
".",
"ID",
"=",
"id",
"\n",
"return",
"ref",... | // NewBinaryReference creates a new BinaryReference with the given name and id | [
"NewBinaryReference",
"creates",
"a",
"new",
"BinaryReference",
"with",
"the",
"given",
"name",
"and",
"id"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/binary.go#L117-L122 |
139,831 | tobischo/gokeepasslib | content.go | readFrom | func (ih *InnerHeader) readFrom(r io.Reader) error {
binaryCount := 0 // Var used to count and index every binary
for {
var headerType byte
var length int32
var data []byte
if err := binary.Read(r, binary.LittleEndian, &headerType); err != nil {
return err
}
if err := binary.Read(r, binary.LittleEndia... | go | func (ih *InnerHeader) readFrom(r io.Reader) error {
binaryCount := 0 // Var used to count and index every binary
for {
var headerType byte
var length int32
var data []byte
if err := binary.Read(r, binary.LittleEndian, &headerType); err != nil {
return err
}
if err := binary.Read(r, binary.LittleEndia... | [
"func",
"(",
"ih",
"*",
"InnerHeader",
")",
"readFrom",
"(",
"r",
"io",
".",
"Reader",
")",
"error",
"{",
"binaryCount",
":=",
"0",
"// Var used to count and index every binary",
"\n",
"for",
"{",
"var",
"headerType",
"byte",
"\n",
"var",
"length",
"int32",
... | // readFrom reads the InnerHeader from an io.Reader | [
"readFrom",
"reads",
"the",
"InnerHeader",
"from",
"an",
"io",
".",
"Reader"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/content.go#L47-L94 |
139,832 | tobischo/gokeepasslib | content.go | writeTo | func (ih *InnerHeader) writeTo(w io.Writer) error {
irsID := make([]byte, 4)
binary.LittleEndian.PutUint32(irsID, ih.InnerRandomStreamID)
if err := writeToInnerHeader(w, InnerHeaderIRSID, irsID); err != nil {
return err
}
if err := writeToInnerHeader(w, InnerHeaderIRSKey, ih.InnerRandomStreamKey); err != nil {
... | go | func (ih *InnerHeader) writeTo(w io.Writer) error {
irsID := make([]byte, 4)
binary.LittleEndian.PutUint32(irsID, ih.InnerRandomStreamID)
if err := writeToInnerHeader(w, InnerHeaderIRSID, irsID); err != nil {
return err
}
if err := writeToInnerHeader(w, InnerHeaderIRSKey, ih.InnerRandomStreamKey); err != nil {
... | [
"func",
"(",
"ih",
"*",
"InnerHeader",
")",
"writeTo",
"(",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"irsID",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"4",
")",
"\n",
"binary",
".",
"LittleEndian",
".",
"PutUint32",
"(",
"irsID",
",",
"ih",
... | // writeTo the InnerHeader to the given io.Writer | [
"writeTo",
"the",
"InnerHeader",
"to",
"the",
"given",
"io",
".",
"Writer"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/content.go#L97-L120 |
139,833 | tobischo/gokeepasslib | hashes.go | readFrom | func (h *DBHashes) readFrom(r io.Reader) error {
return binary.Read(r, binary.LittleEndian, h)
} | go | func (h *DBHashes) readFrom(r io.Reader) error {
return binary.Read(r, binary.LittleEndian, h)
} | [
"func",
"(",
"h",
"*",
"DBHashes",
")",
"readFrom",
"(",
"r",
"io",
".",
"Reader",
")",
"error",
"{",
"return",
"binary",
".",
"Read",
"(",
"r",
",",
"binary",
".",
"LittleEndian",
",",
"h",
")",
"\n",
"}"
] | // readFrom reads the hashes from an io.Reader | [
"readFrom",
"reads",
"the",
"hashes",
"from",
"an",
"io",
".",
"Reader"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/hashes.go#L23-L25 |
139,834 | tobischo/gokeepasslib | hashes.go | writeTo | func (h DBHashes) writeTo(w io.Writer) error {
return binary.Write(w, binary.LittleEndian, h)
} | go | func (h DBHashes) writeTo(w io.Writer) error {
return binary.Write(w, binary.LittleEndian, h)
} | [
"func",
"(",
"h",
"DBHashes",
")",
"writeTo",
"(",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"return",
"binary",
".",
"Write",
"(",
"w",
",",
"binary",
".",
"LittleEndian",
",",
"h",
")",
"\n",
"}"
] | // writeTo writes the hashes to the given io.Writer | [
"writeTo",
"writes",
"the",
"hashes",
"to",
"the",
"given",
"io",
".",
"Writer"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/hashes.go#L28-L30 |
139,835 | tobischo/gokeepasslib | wrappers/time.go | Now | func Now() TimeWrapper {
return TimeWrapper{
Formatted: true,
Time: time.Now().In(time.UTC),
}
} | go | func Now() TimeWrapper {
return TimeWrapper{
Formatted: true,
Time: time.Now().In(time.UTC),
}
} | [
"func",
"Now",
"(",
")",
"TimeWrapper",
"{",
"return",
"TimeWrapper",
"{",
"Formatted",
":",
"true",
",",
"Time",
":",
"time",
".",
"Now",
"(",
")",
".",
"In",
"(",
"time",
".",
"UTC",
")",
",",
"}",
"\n",
"}"
] | // Now returns a TimeWrapper instance with the current time in UTC | [
"Now",
"returns",
"a",
"TimeWrapper",
"instance",
"with",
"the",
"current",
"time",
"in",
"UTC"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/wrappers/time.go#L22-L27 |
139,836 | tobischo/gokeepasslib | crypto/aes.go | NewAESEncrypter | func NewAESEncrypter(key []byte, iv []byte) (*AESEncrypter, error) {
block, err := aes.NewCipher(key)
if err != nil {
return nil, err
}
e := AESEncrypter{
block: block,
encryptionIV: iv,
}
return &e, nil
} | go | func NewAESEncrypter(key []byte, iv []byte) (*AESEncrypter, error) {
block, err := aes.NewCipher(key)
if err != nil {
return nil, err
}
e := AESEncrypter{
block: block,
encryptionIV: iv,
}
return &e, nil
} | [
"func",
"NewAESEncrypter",
"(",
"key",
"[",
"]",
"byte",
",",
"iv",
"[",
"]",
"byte",
")",
"(",
"*",
"AESEncrypter",
",",
"error",
")",
"{",
"block",
",",
"err",
":=",
"aes",
".",
"NewCipher",
"(",
"key",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",... | // NewAESEncrypter initialize a new AESEncrypter interfaced with Encrypter | [
"NewAESEncrypter",
"initialize",
"a",
"new",
"AESEncrypter",
"interfaced",
"with",
"Encrypter"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/crypto/aes.go#L15-L26 |
139,837 | tobischo/gokeepasslib | crypto/chacha.go | NewChaChaEncrypter | func NewChaChaEncrypter(key []byte, iv []byte) (*ChaChaStream, error) {
cipher, err := chacha20.NewCipher(iv, key)
if err != nil {
return nil, err
}
c := ChaChaStream{
cipher: cipher,
}
return &c, nil
} | go | func NewChaChaEncrypter(key []byte, iv []byte) (*ChaChaStream, error) {
cipher, err := chacha20.NewCipher(iv, key)
if err != nil {
return nil, err
}
c := ChaChaStream{
cipher: cipher,
}
return &c, nil
} | [
"func",
"NewChaChaEncrypter",
"(",
"key",
"[",
"]",
"byte",
",",
"iv",
"[",
"]",
"byte",
")",
"(",
"*",
"ChaChaStream",
",",
"error",
")",
"{",
"cipher",
",",
"err",
":=",
"chacha20",
".",
"NewCipher",
"(",
"iv",
",",
"key",
")",
"\n",
"if",
"err",... | // NewChaChaEncrypter initialize a new ChaChaStream interfaced with Encrypter | [
"NewChaChaEncrypter",
"initialize",
"a",
"new",
"ChaChaStream",
"interfaced",
"with",
"Encrypter"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/crypto/chacha.go#L17-L27 |
139,838 | tobischo/gokeepasslib | crypto/chacha.go | NewChaChaStream | func NewChaChaStream(key []byte) (*ChaChaStream, error) {
hash := sha512.Sum512(key)
cipher, err := chacha20.NewCipher(hash[32:44], hash[:32])
if err != nil {
return nil, err
}
c := ChaChaStream{
cipher: cipher,
}
return &c, nil
} | go | func NewChaChaStream(key []byte) (*ChaChaStream, error) {
hash := sha512.Sum512(key)
cipher, err := chacha20.NewCipher(hash[32:44], hash[:32])
if err != nil {
return nil, err
}
c := ChaChaStream{
cipher: cipher,
}
return &c, nil
} | [
"func",
"NewChaChaStream",
"(",
"key",
"[",
"]",
"byte",
")",
"(",
"*",
"ChaChaStream",
",",
"error",
")",
"{",
"hash",
":=",
"sha512",
".",
"Sum512",
"(",
"key",
")",
"\n\n",
"cipher",
",",
"err",
":=",
"chacha20",
".",
"NewCipher",
"(",
"hash",
"["... | // NewChaChaStream initialize a new ChaChaStream interfaced with Stream | [
"NewChaChaStream",
"initialize",
"a",
"new",
"ChaChaStream",
"interfaced",
"with",
"Stream"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/crypto/chacha.go#L30-L42 |
139,839 | tobischo/gokeepasslib | wrappers/bool.go | MarshalXML | func (b *BoolWrapper) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
val := "False"
if *b {
val = "True"
}
e.EncodeElement(val, start)
return nil
} | go | func (b *BoolWrapper) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
val := "False"
if *b {
val = "True"
}
e.EncodeElement(val, start)
return nil
} | [
"func",
"(",
"b",
"*",
"BoolWrapper",
")",
"MarshalXML",
"(",
"e",
"*",
"xml",
".",
"Encoder",
",",
"start",
"xml",
".",
"StartElement",
")",
"error",
"{",
"val",
":=",
"\"",
"\"",
"\n",
"if",
"*",
"b",
"{",
"val",
"=",
"\"",
"\"",
"\n",
"}",
"... | // MarshalXML marshals the boolean into e | [
"MarshalXML",
"marshals",
"the",
"boolean",
"into",
"e"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/wrappers/bool.go#L12-L19 |
139,840 | tobischo/gokeepasslib | wrappers/bool.go | UnmarshalXML | func (b *BoolWrapper) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
var val string
d.DecodeElement(&val, &start)
*b = false
if strings.ToLower(val) == "true" {
*b = true
}
return nil
} | go | func (b *BoolWrapper) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
var val string
d.DecodeElement(&val, &start)
*b = false
if strings.ToLower(val) == "true" {
*b = true
}
return nil
} | [
"func",
"(",
"b",
"*",
"BoolWrapper",
")",
"UnmarshalXML",
"(",
"d",
"*",
"xml",
".",
"Decoder",
",",
"start",
"xml",
".",
"StartElement",
")",
"error",
"{",
"var",
"val",
"string",
"\n",
"d",
".",
"DecodeElement",
"(",
"&",
"val",
",",
"&",
"start",... | // UnmarshalXML unmarshals the boolean from d | [
"UnmarshalXML",
"unmarshals",
"the",
"boolean",
"from",
"d"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/wrappers/bool.go#L22-L32 |
139,841 | tobischo/gokeepasslib | wrappers/bool.go | MarshalXMLAttr | func (b *BoolWrapper) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
val := "False"
if *b {
val = "True"
}
return xml.Attr{Name: name, Value: val}, nil
} | go | func (b *BoolWrapper) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
val := "False"
if *b {
val = "True"
}
return xml.Attr{Name: name, Value: val}, nil
} | [
"func",
"(",
"b",
"*",
"BoolWrapper",
")",
"MarshalXMLAttr",
"(",
"name",
"xml",
".",
"Name",
")",
"(",
"xml",
".",
"Attr",
",",
"error",
")",
"{",
"val",
":=",
"\"",
"\"",
"\n",
"if",
"*",
"b",
"{",
"val",
"=",
"\"",
"\"",
"\n",
"}",
"\n\n",
... | // MarshalXMLAttr returns the encoded XML attribute | [
"MarshalXMLAttr",
"returns",
"the",
"encoded",
"XML",
"attribute"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/wrappers/bool.go#L35-L42 |
139,842 | tobischo/gokeepasslib | wrappers/bool.go | UnmarshalXMLAttr | func (b *BoolWrapper) UnmarshalXMLAttr(attr xml.Attr) error {
*b = false
if strings.ToLower(attr.Value) == "true" {
*b = true
}
return nil
} | go | func (b *BoolWrapper) UnmarshalXMLAttr(attr xml.Attr) error {
*b = false
if strings.ToLower(attr.Value) == "true" {
*b = true
}
return nil
} | [
"func",
"(",
"b",
"*",
"BoolWrapper",
")",
"UnmarshalXMLAttr",
"(",
"attr",
"xml",
".",
"Attr",
")",
"error",
"{",
"*",
"b",
"=",
"false",
"\n",
"if",
"strings",
".",
"ToLower",
"(",
"attr",
".",
"Value",
")",
"==",
"\"",
"\"",
"{",
"*",
"b",
"="... | // UnmarshalXMLAttr decodes a single XML attribute | [
"UnmarshalXMLAttr",
"decodes",
"a",
"single",
"XML",
"attribute"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/wrappers/bool.go#L45-L52 |
139,843 | tobischo/gokeepasslib | crypto.go | NewEncrypterManager | func NewEncrypterManager(key []byte, iv []byte) (manager *EncrypterManager, err error) {
var encrypter Encrypter
manager = new(EncrypterManager)
switch len(iv) {
case 12:
// ChaCha20
encrypter, err = crypto.NewChaChaEncrypter(key, iv)
case 16:
// AES
encrypter, err = crypto.NewAESEncrypter(key, iv)
defaul... | go | func NewEncrypterManager(key []byte, iv []byte) (manager *EncrypterManager, err error) {
var encrypter Encrypter
manager = new(EncrypterManager)
switch len(iv) {
case 12:
// ChaCha20
encrypter, err = crypto.NewChaChaEncrypter(key, iv)
case 16:
// AES
encrypter, err = crypto.NewAESEncrypter(key, iv)
defaul... | [
"func",
"NewEncrypterManager",
"(",
"key",
"[",
"]",
"byte",
",",
"iv",
"[",
"]",
"byte",
")",
"(",
"manager",
"*",
"EncrypterManager",
",",
"err",
"error",
")",
"{",
"var",
"encrypter",
"Encrypter",
"\n",
"manager",
"=",
"new",
"(",
"EncrypterManager",
... | // NewEncrypterManager initialize a new EncrypterManager | [
"NewEncrypterManager",
"initialize",
"a",
"new",
"EncrypterManager"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/crypto.go#L40-L55 |
139,844 | tobischo/gokeepasslib | crypto.go | NewStreamManager | func NewStreamManager(id uint32, key []byte) (manager *StreamManager, err error) {
var stream Stream
manager = new(StreamManager)
switch id {
case NoStreamID:
stream = crypto.NewInsecureStream()
case SalsaStreamID:
stream, err = crypto.NewSalsaStream(key)
case ChaChaStreamID:
stream, err = crypto.NewChaChaS... | go | func NewStreamManager(id uint32, key []byte) (manager *StreamManager, err error) {
var stream Stream
manager = new(StreamManager)
switch id {
case NoStreamID:
stream = crypto.NewInsecureStream()
case SalsaStreamID:
stream, err = crypto.NewSalsaStream(key)
case ChaChaStreamID:
stream, err = crypto.NewChaChaS... | [
"func",
"NewStreamManager",
"(",
"id",
"uint32",
",",
"key",
"[",
"]",
"byte",
")",
"(",
"manager",
"*",
"StreamManager",
",",
"err",
"error",
")",
"{",
"var",
"stream",
"Stream",
"\n",
"manager",
"=",
"new",
"(",
"StreamManager",
")",
"\n",
"switch",
... | // NewStreamManager initialize a new StreamManager | [
"NewStreamManager",
"initialize",
"a",
"new",
"StreamManager"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/crypto.go#L58-L73 |
139,845 | tobischo/gokeepasslib | crypto.go | UnlockProtectedGroups | func (cs *StreamManager) UnlockProtectedGroups(gs []Group) {
for i := range gs { //For each top level group
cs.UnlockProtectedGroup(&gs[i])
}
} | go | func (cs *StreamManager) UnlockProtectedGroups(gs []Group) {
for i := range gs { //For each top level group
cs.UnlockProtectedGroup(&gs[i])
}
} | [
"func",
"(",
"cs",
"*",
"StreamManager",
")",
"UnlockProtectedGroups",
"(",
"gs",
"[",
"]",
"Group",
")",
"{",
"for",
"i",
":=",
"range",
"gs",
"{",
"//For each top level group",
"cs",
".",
"UnlockProtectedGroup",
"(",
"&",
"gs",
"[",
"i",
"]",
")",
"\n"... | // UnlockProtectedGroups unlocks an array of protected groups | [
"UnlockProtectedGroups",
"unlocks",
"an",
"array",
"of",
"protected",
"groups"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/crypto.go#L96-L100 |
139,846 | tobischo/gokeepasslib | crypto.go | UnlockProtectedGroup | func (cs *StreamManager) UnlockProtectedGroup(g *Group) {
cs.UnlockProtectedEntries(g.Entries)
cs.UnlockProtectedGroups(g.Groups)
} | go | func (cs *StreamManager) UnlockProtectedGroup(g *Group) {
cs.UnlockProtectedEntries(g.Entries)
cs.UnlockProtectedGroups(g.Groups)
} | [
"func",
"(",
"cs",
"*",
"StreamManager",
")",
"UnlockProtectedGroup",
"(",
"g",
"*",
"Group",
")",
"{",
"cs",
".",
"UnlockProtectedEntries",
"(",
"g",
".",
"Entries",
")",
"\n",
"cs",
".",
"UnlockProtectedGroups",
"(",
"g",
".",
"Groups",
")",
"\n",
"}"
... | // UnlockProtectedGroup unlocks a protected group | [
"UnlockProtectedGroup",
"unlocks",
"a",
"protected",
"group"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/crypto.go#L103-L106 |
139,847 | tobischo/gokeepasslib | crypto.go | UnlockProtectedEntries | func (cs *StreamManager) UnlockProtectedEntries(e []Entry) {
for i := range e {
cs.UnlockProtectedEntry(&e[i])
}
} | go | func (cs *StreamManager) UnlockProtectedEntries(e []Entry) {
for i := range e {
cs.UnlockProtectedEntry(&e[i])
}
} | [
"func",
"(",
"cs",
"*",
"StreamManager",
")",
"UnlockProtectedEntries",
"(",
"e",
"[",
"]",
"Entry",
")",
"{",
"for",
"i",
":=",
"range",
"e",
"{",
"cs",
".",
"UnlockProtectedEntry",
"(",
"&",
"e",
"[",
"i",
"]",
")",
"\n",
"}",
"\n",
"}"
] | // UnlockProtectedEntries unlocks an array of protected entries | [
"UnlockProtectedEntries",
"unlocks",
"an",
"array",
"of",
"protected",
"entries"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/crypto.go#L109-L113 |
139,848 | tobischo/gokeepasslib | crypto.go | UnlockProtectedEntry | func (cs *StreamManager) UnlockProtectedEntry(e *Entry) {
for i := range e.Values {
if bool(e.Values[i].Value.Protected) {
e.Values[i].Value.Content = string(cs.Unpack(e.Values[i].Value.Content))
}
}
for i := range e.Histories {
cs.UnlockProtectedEntries(e.Histories[i].Entries)
}
} | go | func (cs *StreamManager) UnlockProtectedEntry(e *Entry) {
for i := range e.Values {
if bool(e.Values[i].Value.Protected) {
e.Values[i].Value.Content = string(cs.Unpack(e.Values[i].Value.Content))
}
}
for i := range e.Histories {
cs.UnlockProtectedEntries(e.Histories[i].Entries)
}
} | [
"func",
"(",
"cs",
"*",
"StreamManager",
")",
"UnlockProtectedEntry",
"(",
"e",
"*",
"Entry",
")",
"{",
"for",
"i",
":=",
"range",
"e",
".",
"Values",
"{",
"if",
"bool",
"(",
"e",
".",
"Values",
"[",
"i",
"]",
".",
"Value",
".",
"Protected",
")",
... | // UnlockProtectedEntry unlocks a protected entry | [
"UnlockProtectedEntry",
"unlocks",
"a",
"protected",
"entry"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/crypto.go#L116-L125 |
139,849 | tobischo/gokeepasslib | crypto.go | LockProtectedGroups | func (cs *StreamManager) LockProtectedGroups(gs []Group) {
for i := range gs {
cs.LockProtectedGroup(&gs[i])
}
} | go | func (cs *StreamManager) LockProtectedGroups(gs []Group) {
for i := range gs {
cs.LockProtectedGroup(&gs[i])
}
} | [
"func",
"(",
"cs",
"*",
"StreamManager",
")",
"LockProtectedGroups",
"(",
"gs",
"[",
"]",
"Group",
")",
"{",
"for",
"i",
":=",
"range",
"gs",
"{",
"cs",
".",
"LockProtectedGroup",
"(",
"&",
"gs",
"[",
"i",
"]",
")",
"\n",
"}",
"\n",
"}"
] | // LockProtectedGroups locks an array of unprotected groups | [
"LockProtectedGroups",
"locks",
"an",
"array",
"of",
"unprotected",
"groups"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/crypto.go#L128-L132 |
139,850 | tobischo/gokeepasslib | crypto.go | LockProtectedGroup | func (cs *StreamManager) LockProtectedGroup(g *Group) {
cs.LockProtectedEntries(g.Entries)
cs.LockProtectedGroups(g.Groups)
} | go | func (cs *StreamManager) LockProtectedGroup(g *Group) {
cs.LockProtectedEntries(g.Entries)
cs.LockProtectedGroups(g.Groups)
} | [
"func",
"(",
"cs",
"*",
"StreamManager",
")",
"LockProtectedGroup",
"(",
"g",
"*",
"Group",
")",
"{",
"cs",
".",
"LockProtectedEntries",
"(",
"g",
".",
"Entries",
")",
"\n",
"cs",
".",
"LockProtectedGroups",
"(",
"g",
".",
"Groups",
")",
"\n",
"}"
] | // LockProtectedGroup locks an unprotected group | [
"LockProtectedGroup",
"locks",
"an",
"unprotected",
"group"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/crypto.go#L135-L138 |
139,851 | tobischo/gokeepasslib | crypto.go | LockProtectedEntries | func (cs *StreamManager) LockProtectedEntries(es []Entry) {
for i := range es {
cs.LockProtectedEntry(&es[i])
}
} | go | func (cs *StreamManager) LockProtectedEntries(es []Entry) {
for i := range es {
cs.LockProtectedEntry(&es[i])
}
} | [
"func",
"(",
"cs",
"*",
"StreamManager",
")",
"LockProtectedEntries",
"(",
"es",
"[",
"]",
"Entry",
")",
"{",
"for",
"i",
":=",
"range",
"es",
"{",
"cs",
".",
"LockProtectedEntry",
"(",
"&",
"es",
"[",
"i",
"]",
")",
"\n",
"}",
"\n",
"}"
] | // LockProtectedEntries locks an array of unprotected entries | [
"LockProtectedEntries",
"locks",
"an",
"array",
"of",
"unprotected",
"entries"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/crypto.go#L141-L145 |
139,852 | tobischo/gokeepasslib | crypto.go | LockProtectedEntry | func (cs *StreamManager) LockProtectedEntry(e *Entry) {
for i := range e.Values {
if bool(e.Values[i].Value.Protected) {
e.Values[i].Value.Content = cs.Pack([]byte(e.Values[i].Value.Content))
}
}
for i := range e.Histories {
cs.LockProtectedEntries(e.Histories[i].Entries)
}
} | go | func (cs *StreamManager) LockProtectedEntry(e *Entry) {
for i := range e.Values {
if bool(e.Values[i].Value.Protected) {
e.Values[i].Value.Content = cs.Pack([]byte(e.Values[i].Value.Content))
}
}
for i := range e.Histories {
cs.LockProtectedEntries(e.Histories[i].Entries)
}
} | [
"func",
"(",
"cs",
"*",
"StreamManager",
")",
"LockProtectedEntry",
"(",
"e",
"*",
"Entry",
")",
"{",
"for",
"i",
":=",
"range",
"e",
".",
"Values",
"{",
"if",
"bool",
"(",
"e",
".",
"Values",
"[",
"i",
"]",
".",
"Value",
".",
"Protected",
")",
"... | // LockProtectedEntry locks an unprotected entry | [
"LockProtectedEntry",
"locks",
"an",
"unprotected",
"entry"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/crypto.go#L148-L157 |
139,853 | tobischo/gokeepasslib | decoder.go | Decode | func (d *Decoder) Decode(db *Database) error {
// Read header
db.Header = new(DBHeader)
if err := db.Header.readFrom(d.r); err != nil {
return err
}
// Calculate transformed key to decrypt and calculate HMAC
transformedKey, err := db.getTransformedKey()
if err != nil {
return err
}
// Read hashes and val... | go | func (d *Decoder) Decode(db *Database) error {
// Read header
db.Header = new(DBHeader)
if err := db.Header.readFrom(d.r); err != nil {
return err
}
// Calculate transformed key to decrypt and calculate HMAC
transformedKey, err := db.getTransformedKey()
if err != nil {
return err
}
// Read hashes and val... | [
"func",
"(",
"d",
"*",
"Decoder",
")",
"Decode",
"(",
"db",
"*",
"Database",
")",
"error",
"{",
"// Read header",
"db",
".",
"Header",
"=",
"new",
"(",
"DBHeader",
")",
"\n",
"if",
"err",
":=",
"db",
".",
"Header",
".",
"readFrom",
"(",
"d",
".",
... | // Decode populates given database with the data of Decoder reader | [
"Decode",
"populates",
"given",
"database",
"with",
"the",
"data",
"of",
"Decoder",
"reader"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/decoder.go#L24-L75 |
139,854 | tobischo/gokeepasslib | crypto/salsa.go | NewSalsaStream | func NewSalsaStream(key []byte) (*SalsaStream, error) {
hash := sha256.Sum256(key)
state := make([]uint32, 16)
state[1] = u8to32little(hash[:], 0)
state[2] = u8to32little(hash[:], 4)
state[3] = u8to32little(hash[:], 8)
state[4] = u8to32little(hash[:], 12)
state[11] = u8to32little(hash[:], 16)
state[12] = u8to3... | go | func NewSalsaStream(key []byte) (*SalsaStream, error) {
hash := sha256.Sum256(key)
state := make([]uint32, 16)
state[1] = u8to32little(hash[:], 0)
state[2] = u8to32little(hash[:], 4)
state[3] = u8to32little(hash[:], 8)
state[4] = u8to32little(hash[:], 12)
state[11] = u8to32little(hash[:], 16)
state[12] = u8to3... | [
"func",
"NewSalsaStream",
"(",
"key",
"[",
"]",
"byte",
")",
"(",
"*",
"SalsaStream",
",",
"error",
")",
"{",
"hash",
":=",
"sha256",
".",
"Sum256",
"(",
"key",
")",
"\n",
"state",
":=",
"make",
"(",
"[",
"]",
"uint32",
",",
"16",
")",
"\n\n",
"s... | // NewSalsaStream initialize a new SalsaStream interfaced with CryptoStream | [
"NewSalsaStream",
"initialize",
"a",
"new",
"SalsaStream",
"interfaced",
"with",
"CryptoStream"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/crypto/salsa.go#L25-L53 |
139,855 | tobischo/gokeepasslib | header.go | NewFileHeaders | func NewFileHeaders() *FileHeaders {
masterSeed := make([]byte, 32)
rand.Read(masterSeed)
transformSeed := make([]byte, 32)
rand.Read(transformSeed)
encryptionIV := make([]byte, 16)
rand.Read(encryptionIV)
protectedStreamKey := make([]byte, 32)
rand.Read(protectedStreamKey)
streamStartBytes := make([]byte,... | go | func NewFileHeaders() *FileHeaders {
masterSeed := make([]byte, 32)
rand.Read(masterSeed)
transformSeed := make([]byte, 32)
rand.Read(transformSeed)
encryptionIV := make([]byte, 16)
rand.Read(encryptionIV)
protectedStreamKey := make([]byte, 32)
rand.Read(protectedStreamKey)
streamStartBytes := make([]byte,... | [
"func",
"NewFileHeaders",
"(",
")",
"*",
"FileHeaders",
"{",
"masterSeed",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"32",
")",
"\n",
"rand",
".",
"Read",
"(",
"masterSeed",
")",
"\n\n",
"transformSeed",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"32"... | // NewFileHeaders creates a new FileHeaders with good defaults | [
"NewFileHeaders",
"creates",
"a",
"new",
"FileHeaders",
"with",
"good",
"defaults"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/header.go#L120-L147 |
139,856 | tobischo/gokeepasslib | header.go | readFrom | func (h *DBHeader) readFrom(r io.Reader) error {
// Save read data into a buffer that will be the RawData
buffer := bytes.NewBuffer([]byte{})
tR := io.TeeReader(r, buffer)
// Read signature
h.Signature = new(Signature)
if err := binary.Read(tR, binary.LittleEndian, h.Signature); err != nil {
return err
}
//... | go | func (h *DBHeader) readFrom(r io.Reader) error {
// Save read data into a buffer that will be the RawData
buffer := bytes.NewBuffer([]byte{})
tR := io.TeeReader(r, buffer)
// Read signature
h.Signature = new(Signature)
if err := binary.Read(tR, binary.LittleEndian, h.Signature); err != nil {
return err
}
//... | [
"func",
"(",
"h",
"*",
"DBHeader",
")",
"readFrom",
"(",
"r",
"io",
".",
"Reader",
")",
"error",
"{",
"// Save read data into a buffer that will be the RawData",
"buffer",
":=",
"bytes",
".",
"NewBuffer",
"(",
"[",
"]",
"byte",
"{",
"}",
")",
"\n",
"tR",
"... | // readFrom reads the header from an io.Reader | [
"readFrom",
"reads",
"the",
"header",
"from",
"an",
"io",
".",
"Reader"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/header.go#L150-L182 |
139,857 | tobischo/gokeepasslib | header.go | readHeader4 | func (fh *FileHeaders) readHeader4(r io.Reader) error {
var id uint8
var length uint32
var data []byte
if err := binary.Read(r, binary.LittleEndian, &id); err != nil {
return err
}
if err := binary.Read(r, binary.LittleEndian, &length); err != nil {
return err
}
data = make([]byte, length)
if err := binar... | go | func (fh *FileHeaders) readHeader4(r io.Reader) error {
var id uint8
var length uint32
var data []byte
if err := binary.Read(r, binary.LittleEndian, &id); err != nil {
return err
}
if err := binary.Read(r, binary.LittleEndian, &length); err != nil {
return err
}
data = make([]byte, length)
if err := binar... | [
"func",
"(",
"fh",
"*",
"FileHeaders",
")",
"readHeader4",
"(",
"r",
"io",
".",
"Reader",
")",
"error",
"{",
"var",
"id",
"uint8",
"\n",
"var",
"length",
"uint32",
"\n",
"var",
"data",
"[",
"]",
"byte",
"\n\n",
"if",
"err",
":=",
"binary",
".",
"Re... | // readHeader4 reads a header of a KDBX v4 database | [
"readHeader4",
"reads",
"a",
"header",
"of",
"a",
"KDBX",
"v4",
"database"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/header.go#L185-L202 |
139,858 | tobischo/gokeepasslib | header.go | readFileHeader | func (fh *FileHeaders) readFileHeader(id uint8, data []byte) error {
switch id {
case 0:
return ErrEndOfHeaders
case 1:
fh.Comment = data
case 2:
fh.CipherID = data
case 3:
fh.CompressionFlags = binary.LittleEndian.Uint32(data)
case 4:
fh.MasterSeed = data
case 5:
fh.TransformSeed = data
case 6:
f... | go | func (fh *FileHeaders) readFileHeader(id uint8, data []byte) error {
switch id {
case 0:
return ErrEndOfHeaders
case 1:
fh.Comment = data
case 2:
fh.CipherID = data
case 3:
fh.CompressionFlags = binary.LittleEndian.Uint32(data)
case 4:
fh.MasterSeed = data
case 5:
fh.TransformSeed = data
case 6:
f... | [
"func",
"(",
"fh",
"*",
"FileHeaders",
")",
"readFileHeader",
"(",
"id",
"uint8",
",",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"switch",
"id",
"{",
"case",
"0",
":",
"return",
"ErrEndOfHeaders",
"\n",
"case",
"1",
":",
"fh",
".",
"Comment",
"=",... | // readFileHeader reads a header value and puts it into the right variable | [
"readFileHeader",
"reads",
"a",
"header",
"value",
"and",
"puts",
"it",
"into",
"the",
"right",
"variable"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/header.go#L225-L259 |
139,859 | tobischo/gokeepasslib | header.go | readKdfParameters | func (k *KdfParameters) readKdfParameters(data []byte) error {
dict := new(VariantDictionary)
if err := dict.readVariantDictionary(data); err != nil {
return err
}
k.RawData = dict
for _, item := range dict.Items {
switch string(item.Name) {
case "$UUID":
k.UUID = item.Value
case "R":
k.Rounds = bin... | go | func (k *KdfParameters) readKdfParameters(data []byte) error {
dict := new(VariantDictionary)
if err := dict.readVariantDictionary(data); err != nil {
return err
}
k.RawData = dict
for _, item := range dict.Items {
switch string(item.Name) {
case "$UUID":
k.UUID = item.Value
case "R":
k.Rounds = bin... | [
"func",
"(",
"k",
"*",
"KdfParameters",
")",
"readKdfParameters",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"dict",
":=",
"new",
"(",
"VariantDictionary",
")",
"\n",
"if",
"err",
":=",
"dict",
".",
"readVariantDictionary",
"(",
"data",
")",
";",
... | // readKdfParameters reads a variant dictionary and puts values into KdfParameters | [
"readKdfParameters",
"reads",
"a",
"variant",
"dictionary",
"and",
"puts",
"values",
"into",
"KdfParameters"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/header.go#L262-L294 |
139,860 | tobischo/gokeepasslib | header.go | readVariantDictionary | func (vd *VariantDictionary) readVariantDictionary(data []byte) error {
r := bytes.NewReader(data)
if err := binary.Read(r, binary.LittleEndian, &vd.Version); err != nil {
return err
}
for {
vdi := new(VariantDictionaryItem)
if err := binary.Read(r, binary.LittleEndian, &vdi.Type); err != nil {
return er... | go | func (vd *VariantDictionary) readVariantDictionary(data []byte) error {
r := bytes.NewReader(data)
if err := binary.Read(r, binary.LittleEndian, &vd.Version); err != nil {
return err
}
for {
vdi := new(VariantDictionaryItem)
if err := binary.Read(r, binary.LittleEndian, &vdi.Type); err != nil {
return er... | [
"func",
"(",
"vd",
"*",
"VariantDictionary",
")",
"readVariantDictionary",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"r",
":=",
"bytes",
".",
"NewReader",
"(",
"data",
")",
"\n\n",
"if",
"err",
":=",
"binary",
".",
"Read",
"(",
"r",
",",
"bin... | // readVariantDictionary reads a variant dictionary | [
"readVariantDictionary",
"reads",
"a",
"variant",
"dictionary"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/header.go#L297-L333 |
139,861 | tobischo/gokeepasslib | header.go | writeTo | func (h *DBHeader) writeTo(w io.Writer) error {
var buffer bytes.Buffer
mw := io.MultiWriter(w, &buffer)
binary.Write(mw, binary.LittleEndian, h.Signature)
if h.IsKdbx4() {
h.FileHeaders.writeTo4(mw, &buffer)
} else {
h.FileHeaders.writeTo31(mw)
}
h.RawData = buffer.Bytes()
return nil
} | go | func (h *DBHeader) writeTo(w io.Writer) error {
var buffer bytes.Buffer
mw := io.MultiWriter(w, &buffer)
binary.Write(mw, binary.LittleEndian, h.Signature)
if h.IsKdbx4() {
h.FileHeaders.writeTo4(mw, &buffer)
} else {
h.FileHeaders.writeTo31(mw)
}
h.RawData = buffer.Bytes()
return nil
} | [
"func",
"(",
"h",
"*",
"DBHeader",
")",
"writeTo",
"(",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"var",
"buffer",
"bytes",
".",
"Buffer",
"\n",
"mw",
":=",
"io",
".",
"MultiWriter",
"(",
"w",
",",
"&",
"buffer",
")",
"\n\n",
"binary",
".",
"W... | // writeTo writes the header to the given io.Writer | [
"writeTo",
"writes",
"the",
"header",
"to",
"the",
"given",
"io",
".",
"Writer"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/header.go#L336-L351 |
139,862 | tobischo/gokeepasslib | header.go | writeTo4 | func (fh FileHeaders) writeTo4(w io.Writer, buf *bytes.Buffer) error {
compressionFlags := make([]byte, 4)
binary.LittleEndian.PutUint32(compressionFlags, fh.CompressionFlags)
if err := writeTo4Header(w, 1, fh.Comment); err != nil {
return err
}
if err := writeTo4Header(w, 2, fh.CipherID); err != nil {
return... | go | func (fh FileHeaders) writeTo4(w io.Writer, buf *bytes.Buffer) error {
compressionFlags := make([]byte, 4)
binary.LittleEndian.PutUint32(compressionFlags, fh.CompressionFlags)
if err := writeTo4Header(w, 1, fh.Comment); err != nil {
return err
}
if err := writeTo4Header(w, 2, fh.CipherID); err != nil {
return... | [
"func",
"(",
"fh",
"FileHeaders",
")",
"writeTo4",
"(",
"w",
"io",
".",
"Writer",
",",
"buf",
"*",
"bytes",
".",
"Buffer",
")",
"error",
"{",
"compressionFlags",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"4",
")",
"\n",
"binary",
".",
"LittleEndian",... | // writeTo4 writes a Kdbx v4 structured file header to the given io.Writer | [
"writeTo4",
"writes",
"a",
"Kdbx",
"v4",
"structured",
"file",
"header",
"to",
"the",
"given",
"io",
".",
"Writer"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/header.go#L354-L381 |
139,863 | tobischo/gokeepasslib | header.go | writeTo4Header | func writeTo4Header(w io.Writer, id uint8, data []byte) error {
if len(data) > 0 {
if err := binary.Write(w, binary.LittleEndian, id); err != nil {
return err
}
if err := binary.Write(w, binary.LittleEndian, uint32(len(data))); err != nil {
return err
}
if err := binary.Write(w, binary.LittleEndian, da... | go | func writeTo4Header(w io.Writer, id uint8, data []byte) error {
if len(data) > 0 {
if err := binary.Write(w, binary.LittleEndian, id); err != nil {
return err
}
if err := binary.Write(w, binary.LittleEndian, uint32(len(data))); err != nil {
return err
}
if err := binary.Write(w, binary.LittleEndian, da... | [
"func",
"writeTo4Header",
"(",
"w",
"io",
".",
"Writer",
",",
"id",
"uint8",
",",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"len",
"(",
"data",
")",
">",
"0",
"{",
"if",
"err",
":=",
"binary",
".",
"Write",
"(",
"w",
",",
"binary",
"."... | // writeTo4Header is an helper to write a file header with the correct Kdbx v4 structure to the given io.Writer | [
"writeTo4Header",
"is",
"an",
"helper",
"to",
"write",
"a",
"file",
"header",
"with",
"the",
"correct",
"Kdbx",
"v4",
"structure",
"to",
"the",
"given",
"io",
".",
"Writer"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/header.go#L384-L397 |
139,864 | tobischo/gokeepasslib | header.go | writeTo4VariantDictionary | func writeTo4VariantDictionary(w io.Writer, id uint8, data *VariantDictionary) error {
if data != nil {
var buffer bytes.Buffer
if err := binary.Write(&buffer, binary.LittleEndian, data.Version); err != nil {
return err
}
for _, item := range data.Items {
if err := binary.Write(&buffer, binary.LittleEndi... | go | func writeTo4VariantDictionary(w io.Writer, id uint8, data *VariantDictionary) error {
if data != nil {
var buffer bytes.Buffer
if err := binary.Write(&buffer, binary.LittleEndian, data.Version); err != nil {
return err
}
for _, item := range data.Items {
if err := binary.Write(&buffer, binary.LittleEndi... | [
"func",
"writeTo4VariantDictionary",
"(",
"w",
"io",
".",
"Writer",
",",
"id",
"uint8",
",",
"data",
"*",
"VariantDictionary",
")",
"error",
"{",
"if",
"data",
"!=",
"nil",
"{",
"var",
"buffer",
"bytes",
".",
"Buffer",
"\n",
"if",
"err",
":=",
"binary",
... | // writeTo31Header is an helper to write a variant dictionary to the given io.Writer | [
"writeTo31Header",
"is",
"an",
"helper",
"to",
"write",
"a",
"variant",
"dictionary",
"to",
"the",
"given",
"io",
".",
"Writer"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/header.go#L400-L439 |
139,865 | tobischo/gokeepasslib | header.go | writeTo31 | func (fh FileHeaders) writeTo31(w io.Writer) error {
compressionFlags := make([]byte, 4)
binary.LittleEndian.PutUint32(compressionFlags, fh.CompressionFlags)
transformRounds := make([]byte, 8)
binary.LittleEndian.PutUint64(transformRounds, fh.TransformRounds)
innerRandomStreamID := make([]byte, 4)
binary.Little... | go | func (fh FileHeaders) writeTo31(w io.Writer) error {
compressionFlags := make([]byte, 4)
binary.LittleEndian.PutUint32(compressionFlags, fh.CompressionFlags)
transformRounds := make([]byte, 8)
binary.LittleEndian.PutUint64(transformRounds, fh.TransformRounds)
innerRandomStreamID := make([]byte, 4)
binary.Little... | [
"func",
"(",
"fh",
"FileHeaders",
")",
"writeTo31",
"(",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"compressionFlags",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"4",
")",
"\n",
"binary",
".",
"LittleEndian",
".",
"PutUint32",
"(",
"compressionFlags",
... | // writeTo31 writes a Kdbx v3.1 structured file header to the given io.Writer | [
"writeTo31",
"writes",
"a",
"Kdbx",
"v3",
".",
"1",
"structured",
"file",
"header",
"to",
"the",
"given",
"io",
".",
"Writer"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/header.go#L442-L484 |
139,866 | tobischo/gokeepasslib | header.go | writeTo31Header | func writeTo31Header(w io.Writer, id uint8, data []byte) error {
if len(data) > 0 {
if err := binary.Write(w, binary.LittleEndian, id); err != nil {
return err
}
if err := binary.Write(w, binary.LittleEndian, uint16(len(data))); err != nil {
return err
}
if err := binary.Write(w, binary.LittleEndian, d... | go | func writeTo31Header(w io.Writer, id uint8, data []byte) error {
if len(data) > 0 {
if err := binary.Write(w, binary.LittleEndian, id); err != nil {
return err
}
if err := binary.Write(w, binary.LittleEndian, uint16(len(data))); err != nil {
return err
}
if err := binary.Write(w, binary.LittleEndian, d... | [
"func",
"writeTo31Header",
"(",
"w",
"io",
".",
"Writer",
",",
"id",
"uint8",
",",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"len",
"(",
"data",
")",
">",
"0",
"{",
"if",
"err",
":=",
"binary",
".",
"Write",
"(",
"w",
",",
"binary",
".... | // writeTo31Header is an helper to write a file header with the correct Kdbx v3.1 structure to the given io.Writer | [
"writeTo31Header",
"is",
"an",
"helper",
"to",
"write",
"a",
"file",
"header",
"with",
"the",
"correct",
"Kdbx",
"v3",
".",
"1",
"structure",
"to",
"the",
"given",
"io",
".",
"Writer"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/header.go#L487-L500 |
139,867 | tobischo/gokeepasslib | header.go | Get | func (vd *VariantDictionary) Get(key string) *VariantDictionaryItem {
for _, item := range vd.Items {
if string(item.Name) == key {
return item
}
}
return nil
} | go | func (vd *VariantDictionary) Get(key string) *VariantDictionaryItem {
for _, item := range vd.Items {
if string(item.Name) == key {
return item
}
}
return nil
} | [
"func",
"(",
"vd",
"*",
"VariantDictionary",
")",
"Get",
"(",
"key",
"string",
")",
"*",
"VariantDictionaryItem",
"{",
"for",
"_",
",",
"item",
":=",
"range",
"vd",
".",
"Items",
"{",
"if",
"string",
"(",
"item",
".",
"Name",
")",
"==",
"key",
"{",
... | // Get a VariantDictionaryItem via its key | [
"Get",
"a",
"VariantDictionaryItem",
"via",
"its",
"key"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/header.go#L503-L510 |
139,868 | tobischo/gokeepasslib | header.go | ValidateSha256 | func (h *DBHeader) ValidateSha256(hash [32]byte) error {
sha := h.GetSha256()
if !reflect.DeepEqual(sha, hash) {
return errors.New("Sha256 of header mismatching")
}
return nil
} | go | func (h *DBHeader) ValidateSha256(hash [32]byte) error {
sha := h.GetSha256()
if !reflect.DeepEqual(sha, hash) {
return errors.New("Sha256 of header mismatching")
}
return nil
} | [
"func",
"(",
"h",
"*",
"DBHeader",
")",
"ValidateSha256",
"(",
"hash",
"[",
"32",
"]",
"byte",
")",
"error",
"{",
"sha",
":=",
"h",
".",
"GetSha256",
"(",
")",
"\n",
"if",
"!",
"reflect",
".",
"DeepEqual",
"(",
"sha",
",",
"hash",
")",
"{",
"retu... | // ValidateSha256 validates the given hash with the Sha256 of the header | [
"ValidateSha256",
"validates",
"the",
"given",
"hash",
"with",
"the",
"Sha256",
"of",
"the",
"header"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/header.go#L523-L529 |
139,869 | tobischo/gokeepasslib | header.go | GetHmacSha256 | func (h *DBHeader) GetHmacSha256(hmacKey []byte) (ret [32]byte) {
hash := hmac.New(sha256.New, hmacKey)
hash.Write(h.RawData)
copy(ret[:32], hash.Sum(nil)[:32])
return
} | go | func (h *DBHeader) GetHmacSha256(hmacKey []byte) (ret [32]byte) {
hash := hmac.New(sha256.New, hmacKey)
hash.Write(h.RawData)
copy(ret[:32], hash.Sum(nil)[:32])
return
} | [
"func",
"(",
"h",
"*",
"DBHeader",
")",
"GetHmacSha256",
"(",
"hmacKey",
"[",
"]",
"byte",
")",
"(",
"ret",
"[",
"32",
"]",
"byte",
")",
"{",
"hash",
":=",
"hmac",
".",
"New",
"(",
"sha256",
".",
"New",
",",
"hmacKey",
")",
"\n",
"hash",
".",
"... | // GetHmacSha256 returns the HMAC-Sha256 hash of the header | [
"GetHmacSha256",
"returns",
"the",
"HMAC",
"-",
"Sha256",
"hash",
"of",
"the",
"header"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/header.go#L532-L537 |
139,870 | tobischo/gokeepasslib | header.go | ValidateHmacSha256 | func (h *DBHeader) ValidateHmacSha256(hmacKey []byte, hash [32]byte) error {
hmacSha := h.GetHmacSha256(hmacKey)
if !reflect.DeepEqual(hmacSha, hash) {
return errors.New("HMAC-Sha256 of header mismatching")
}
return nil
} | go | func (h *DBHeader) ValidateHmacSha256(hmacKey []byte, hash [32]byte) error {
hmacSha := h.GetHmacSha256(hmacKey)
if !reflect.DeepEqual(hmacSha, hash) {
return errors.New("HMAC-Sha256 of header mismatching")
}
return nil
} | [
"func",
"(",
"h",
"*",
"DBHeader",
")",
"ValidateHmacSha256",
"(",
"hmacKey",
"[",
"]",
"byte",
",",
"hash",
"[",
"32",
"]",
"byte",
")",
"error",
"{",
"hmacSha",
":=",
"h",
".",
"GetHmacSha256",
"(",
"hmacKey",
")",
"\n",
"if",
"!",
"reflect",
".",
... | // ValidateHmacSha256 validates the given hash with the HMAC-Sha256 of the header | [
"ValidateHmacSha256",
"validates",
"the",
"given",
"hash",
"with",
"the",
"HMAC",
"-",
"Sha256",
"of",
"the",
"header"
] | 8892e349f7674fa2214afba77de81fd6dfc44507 | https://github.com/tobischo/gokeepasslib/blob/8892e349f7674fa2214afba77de81fd6dfc44507/header.go#L540-L546 |
139,871 | restic/chunker | polynomials.go | Add | func (x Pol) Add(y Pol) Pol {
r := Pol(uint64(x) ^ uint64(y))
return r
} | go | func (x Pol) Add(y Pol) Pol {
r := Pol(uint64(x) ^ uint64(y))
return r
} | [
"func",
"(",
"x",
"Pol",
")",
"Add",
"(",
"y",
"Pol",
")",
"Pol",
"{",
"r",
":=",
"Pol",
"(",
"uint64",
"(",
"x",
")",
"^",
"uint64",
"(",
"y",
")",
")",
"\n",
"return",
"r",
"\n",
"}"
] | // Add returns x+y. | [
"Add",
"returns",
"x",
"+",
"y",
"."
] | 43a9dae2133895ca2eadc5c187b4ce00e5b73cdc | https://github.com/restic/chunker/blob/43a9dae2133895ca2eadc5c187b4ce00e5b73cdc/polynomials.go#L16-L19 |
139,872 | restic/chunker | polynomials.go | Expand | func (x Pol) Expand() string {
if x == 0 {
return "0"
}
s := ""
for i := x.Deg(); i > 1; i-- {
if x&(1<<uint(i)) > 0 {
s += fmt.Sprintf("+x^%d", i)
}
}
if x&2 > 0 {
s += "+x"
}
if x&1 > 0 {
s += "+1"
}
return s[1:]
} | go | func (x Pol) Expand() string {
if x == 0 {
return "0"
}
s := ""
for i := x.Deg(); i > 1; i-- {
if x&(1<<uint(i)) > 0 {
s += fmt.Sprintf("+x^%d", i)
}
}
if x&2 > 0 {
s += "+x"
}
if x&1 > 0 {
s += "+1"
}
return s[1:]
} | [
"func",
"(",
"x",
"Pol",
")",
"Expand",
"(",
")",
"string",
"{",
"if",
"x",
"==",
"0",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"s",
":=",
"\"",
"\"",
"\n",
"for",
"i",
":=",
"x",
".",
"Deg",
"(",
")",
";",
"i",
">",
"1",
";",
"i",
... | // Expand returns the string representation of the polynomial x. | [
"Expand",
"returns",
"the",
"string",
"representation",
"of",
"the",
"polynomial",
"x",
"."
] | 43a9dae2133895ca2eadc5c187b4ce00e5b73cdc | https://github.com/restic/chunker/blob/43a9dae2133895ca2eadc5c187b4ce00e5b73cdc/polynomials.go#L109-L130 |
139,873 | restic/chunker | polynomials.go | GCD | func (x Pol) GCD(f Pol) Pol {
if f == 0 {
return x
}
if x == 0 {
return f
}
if x.Deg() < f.Deg() {
x, f = f, x
}
return f.GCD(x.Mod(f))
} | go | func (x Pol) GCD(f Pol) Pol {
if f == 0 {
return x
}
if x == 0 {
return f
}
if x.Deg() < f.Deg() {
x, f = f, x
}
return f.GCD(x.Mod(f))
} | [
"func",
"(",
"x",
"Pol",
")",
"GCD",
"(",
"f",
"Pol",
")",
"Pol",
"{",
"if",
"f",
"==",
"0",
"{",
"return",
"x",
"\n",
"}",
"\n\n",
"if",
"x",
"==",
"0",
"{",
"return",
"f",
"\n",
"}",
"\n\n",
"if",
"x",
".",
"Deg",
"(",
")",
"<",
"f",
... | // GCD computes the Greatest Common Divisor x and f. | [
"GCD",
"computes",
"the",
"Greatest",
"Common",
"Divisor",
"x",
"and",
"f",
"."
] | 43a9dae2133895ca2eadc5c187b4ce00e5b73cdc | https://github.com/restic/chunker/blob/43a9dae2133895ca2eadc5c187b4ce00e5b73cdc/polynomials.go#L221-L235 |
139,874 | restic/chunker | polynomials.go | Irreducible | func (x Pol) Irreducible() bool {
for i := 1; i <= x.Deg()/2; i++ {
if x.GCD(qp(uint(i), x)) != 1 {
return false
}
}
return true
} | go | func (x Pol) Irreducible() bool {
for i := 1; i <= x.Deg()/2; i++ {
if x.GCD(qp(uint(i), x)) != 1 {
return false
}
}
return true
} | [
"func",
"(",
"x",
"Pol",
")",
"Irreducible",
"(",
")",
"bool",
"{",
"for",
"i",
":=",
"1",
";",
"i",
"<=",
"x",
".",
"Deg",
"(",
")",
"/",
"2",
";",
"i",
"++",
"{",
"if",
"x",
".",
"GCD",
"(",
"qp",
"(",
"uint",
"(",
"i",
")",
",",
"x",... | // Irreducible returns true iff x is irreducible over F_2. This function
// uses Ben Or's reducibility test.
//
// For details see "Tests and Constructions of Irreducible Polynomials over
// Finite Fields". | [
"Irreducible",
"returns",
"true",
"iff",
"x",
"is",
"irreducible",
"over",
"F_2",
".",
"This",
"function",
"uses",
"Ben",
"Or",
"s",
"reducibility",
"test",
".",
"For",
"details",
"see",
"Tests",
"and",
"Constructions",
"of",
"Irreducible",
"Polynomials",
"ove... | 43a9dae2133895ca2eadc5c187b4ce00e5b73cdc | https://github.com/restic/chunker/blob/43a9dae2133895ca2eadc5c187b4ce00e5b73cdc/polynomials.go#L242-L250 |
139,875 | restic/chunker | polynomials.go | MarshalJSON | func (x Pol) MarshalJSON() ([]byte, error) {
buf := strconv.AppendUint([]byte{'"'}, uint64(x), 16)
buf = append(buf, '"')
return buf, nil
} | go | func (x Pol) MarshalJSON() ([]byte, error) {
buf := strconv.AppendUint([]byte{'"'}, uint64(x), 16)
buf = append(buf, '"')
return buf, nil
} | [
"func",
"(",
"x",
"Pol",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"buf",
":=",
"strconv",
".",
"AppendUint",
"(",
"[",
"]",
"byte",
"{",
"'\"'",
"}",
",",
"uint64",
"(",
"x",
")",
",",
"16",
")",
"\n",
"buf... | // MarshalJSON returns the JSON representation of the Pol. | [
"MarshalJSON",
"returns",
"the",
"JSON",
"representation",
"of",
"the",
"Pol",
"."
] | 43a9dae2133895ca2eadc5c187b4ce00e5b73cdc | https://github.com/restic/chunker/blob/43a9dae2133895ca2eadc5c187b4ce00e5b73cdc/polynomials.go#L292-L296 |
139,876 | restic/chunker | polynomials.go | UnmarshalJSON | func (x *Pol) UnmarshalJSON(data []byte) error {
if len(data) < 2 {
return errors.New("invalid string for polynomial")
}
n, err := strconv.ParseUint(string(data[1:len(data)-1]), 16, 64)
if err != nil {
return err
}
*x = Pol(n)
return nil
} | go | func (x *Pol) UnmarshalJSON(data []byte) error {
if len(data) < 2 {
return errors.New("invalid string for polynomial")
}
n, err := strconv.ParseUint(string(data[1:len(data)-1]), 16, 64)
if err != nil {
return err
}
*x = Pol(n)
return nil
} | [
"func",
"(",
"x",
"*",
"Pol",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"len",
"(",
"data",
")",
"<",
"2",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"n",
",",
"err",
":=",
... | // UnmarshalJSON parses a Pol from the JSON data. | [
"UnmarshalJSON",
"parses",
"a",
"Pol",
"from",
"the",
"JSON",
"data",
"."
] | 43a9dae2133895ca2eadc5c187b4ce00e5b73cdc | https://github.com/restic/chunker/blob/43a9dae2133895ca2eadc5c187b4ce00e5b73cdc/polynomials.go#L299-L310 |
139,877 | restic/chunker | chunker.go | New | func New(rd io.Reader, pol Pol) *Chunker {
return NewWithBoundaries(rd, pol, MinSize, MaxSize)
} | go | func New(rd io.Reader, pol Pol) *Chunker {
return NewWithBoundaries(rd, pol, MinSize, MaxSize)
} | [
"func",
"New",
"(",
"rd",
"io",
".",
"Reader",
",",
"pol",
"Pol",
")",
"*",
"Chunker",
"{",
"return",
"NewWithBoundaries",
"(",
"rd",
",",
"pol",
",",
"MinSize",
",",
"MaxSize",
")",
"\n",
"}"
] | // New returns a new Chunker based on polynomial p that reads from rd. | [
"New",
"returns",
"a",
"new",
"Chunker",
"based",
"on",
"polynomial",
"p",
"that",
"reads",
"from",
"rd",
"."
] | 43a9dae2133895ca2eadc5c187b4ce00e5b73cdc | https://github.com/restic/chunker/blob/43a9dae2133895ca2eadc5c187b4ce00e5b73cdc/chunker.go#L92-L94 |
139,878 | restic/chunker | chunker.go | NewWithBoundaries | func NewWithBoundaries(rd io.Reader, pol Pol, min, max uint) *Chunker {
c := &Chunker{
chunkerState: chunkerState{
buf: make([]byte, chunkerBufSize),
},
chunkerConfig: chunkerConfig{
pol: pol,
rd: rd,
MinSize: min,
MaxSize: max,
splitmask: (1 << 20) - 1, // aim to create chunks... | go | func NewWithBoundaries(rd io.Reader, pol Pol, min, max uint) *Chunker {
c := &Chunker{
chunkerState: chunkerState{
buf: make([]byte, chunkerBufSize),
},
chunkerConfig: chunkerConfig{
pol: pol,
rd: rd,
MinSize: min,
MaxSize: max,
splitmask: (1 << 20) - 1, // aim to create chunks... | [
"func",
"NewWithBoundaries",
"(",
"rd",
"io",
".",
"Reader",
",",
"pol",
"Pol",
",",
"min",
",",
"max",
"uint",
")",
"*",
"Chunker",
"{",
"c",
":=",
"&",
"Chunker",
"{",
"chunkerState",
":",
"chunkerState",
"{",
"buf",
":",
"make",
"(",
"[",
"]",
"... | // NewWithBoundaries returns a new Chunker based on polynomial p that reads from
// rd and custom min and max size boundaries. | [
"NewWithBoundaries",
"returns",
"a",
"new",
"Chunker",
"based",
"on",
"polynomial",
"p",
"that",
"reads",
"from",
"rd",
"and",
"custom",
"min",
"and",
"max",
"size",
"boundaries",
"."
] | 43a9dae2133895ca2eadc5c187b4ce00e5b73cdc | https://github.com/restic/chunker/blob/43a9dae2133895ca2eadc5c187b4ce00e5b73cdc/chunker.go#L98-L115 |
139,879 | restic/chunker | chunker.go | Reset | func (c *Chunker) Reset(rd io.Reader, pol Pol) {
c.ResetWithBoundaries(rd, pol, MinSize, MaxSize)
} | go | func (c *Chunker) Reset(rd io.Reader, pol Pol) {
c.ResetWithBoundaries(rd, pol, MinSize, MaxSize)
} | [
"func",
"(",
"c",
"*",
"Chunker",
")",
"Reset",
"(",
"rd",
"io",
".",
"Reader",
",",
"pol",
"Pol",
")",
"{",
"c",
".",
"ResetWithBoundaries",
"(",
"rd",
",",
"pol",
",",
"MinSize",
",",
"MaxSize",
")",
"\n",
"}"
] | // Reset reinitializes the chunker with a new reader and polynomial. | [
"Reset",
"reinitializes",
"the",
"chunker",
"with",
"a",
"new",
"reader",
"and",
"polynomial",
"."
] | 43a9dae2133895ca2eadc5c187b4ce00e5b73cdc | https://github.com/restic/chunker/blob/43a9dae2133895ca2eadc5c187b4ce00e5b73cdc/chunker.go#L118-L120 |
139,880 | restic/chunker | chunker.go | ResetWithBoundaries | func (c *Chunker) ResetWithBoundaries(rd io.Reader, pol Pol, min, max uint) {
*c = Chunker{
chunkerState: chunkerState{
buf: c.buf,
},
chunkerConfig: chunkerConfig{
pol: pol,
rd: rd,
MinSize: min,
MaxSize: max,
splitmask: (1 << 20) - 1,
},
}
c.reset()
} | go | func (c *Chunker) ResetWithBoundaries(rd io.Reader, pol Pol, min, max uint) {
*c = Chunker{
chunkerState: chunkerState{
buf: c.buf,
},
chunkerConfig: chunkerConfig{
pol: pol,
rd: rd,
MinSize: min,
MaxSize: max,
splitmask: (1 << 20) - 1,
},
}
c.reset()
} | [
"func",
"(",
"c",
"*",
"Chunker",
")",
"ResetWithBoundaries",
"(",
"rd",
"io",
".",
"Reader",
",",
"pol",
"Pol",
",",
"min",
",",
"max",
"uint",
")",
"{",
"*",
"c",
"=",
"Chunker",
"{",
"chunkerState",
":",
"chunkerState",
"{",
"buf",
":",
"c",
"."... | // ResetWithBoundaries reinitializes the chunker with a new reader, polynomial
// and custom min and max size boundaries. | [
"ResetWithBoundaries",
"reinitializes",
"the",
"chunker",
"with",
"a",
"new",
"reader",
"polynomial",
"and",
"custom",
"min",
"and",
"max",
"size",
"boundaries",
"."
] | 43a9dae2133895ca2eadc5c187b4ce00e5b73cdc | https://github.com/restic/chunker/blob/43a9dae2133895ca2eadc5c187b4ce00e5b73cdc/chunker.go#L124-L139 |
139,881 | restic/chunker | chunker.go | fillTables | func (c *Chunker) fillTables() {
// if polynomial hasn't been specified, do not compute anything for now
if c.pol == 0 {
return
}
c.tablesInitialized = true
// test if the tables are cached for this polynomial
cache.Lock()
defer cache.Unlock()
if t, ok := cache.entries[c.pol]; ok {
c.tables = t
return
... | go | func (c *Chunker) fillTables() {
// if polynomial hasn't been specified, do not compute anything for now
if c.pol == 0 {
return
}
c.tablesInitialized = true
// test if the tables are cached for this polynomial
cache.Lock()
defer cache.Unlock()
if t, ok := cache.entries[c.pol]; ok {
c.tables = t
return
... | [
"func",
"(",
"c",
"*",
"Chunker",
")",
"fillTables",
"(",
")",
"{",
"// if polynomial hasn't been specified, do not compute anything for now",
"if",
"c",
".",
"pol",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n\n",
"c",
".",
"tablesInitialized",
"=",
"true",
"\n\n",... | // fillTables calculates out_table and mod_table for optimization. This
// implementation uses a cache in the global variable cache. | [
"fillTables",
"calculates",
"out_table",
"and",
"mod_table",
"for",
"optimization",
".",
"This",
"implementation",
"uses",
"a",
"cache",
"in",
"the",
"global",
"variable",
"cache",
"."
] | 43a9dae2133895ca2eadc5c187b4ce00e5b73cdc | https://github.com/restic/chunker/blob/43a9dae2133895ca2eadc5c187b4ce00e5b73cdc/chunker.go#L162-L213 |
139,882 | dchest/stemmer | dutch/dutch.go | deleteESuffixPrecededByNonVowel | func deleteESuffixPrecededByNonVowel(s []rune, r1 int) ([]rune, bool) {
if i := len(s) - 1; i >= r1 && s[i] == 'e' && !isVowelAt(s, i-1) {
s = s[:i]
return s, true
}
return s, false
} | go | func deleteESuffixPrecededByNonVowel(s []rune, r1 int) ([]rune, bool) {
if i := len(s) - 1; i >= r1 && s[i] == 'e' && !isVowelAt(s, i-1) {
s = s[:i]
return s, true
}
return s, false
} | [
"func",
"deleteESuffixPrecededByNonVowel",
"(",
"s",
"[",
"]",
"rune",
",",
"r1",
"int",
")",
"(",
"[",
"]",
"rune",
",",
"bool",
")",
"{",
"if",
"i",
":=",
"len",
"(",
"s",
")",
"-",
"1",
";",
"i",
">=",
"r1",
"&&",
"s",
"[",
"i",
"]",
"==",... | // Delete suffix e if in R1 and preceded by a non-vowel | [
"Delete",
"suffix",
"e",
"if",
"in",
"R1",
"and",
"preceded",
"by",
"a",
"non",
"-",
"vowel"
] | 66719a20c4b5d119ff43ef41aab03265a3d644a7 | https://github.com/dchest/stemmer/blob/66719a20c4b5d119ff43ef41aab03265a3d644a7/dutch/dutch.go#L102-L108 |
139,883 | steveyen/gkvlite | collection.go | Get | func (t *Collection) Get(key []byte) (val []byte, err error) {
i, err := t.GetItem(key, true)
if err != nil {
return nil, err
}
if i != nil {
return i.Val, nil
}
return nil, nil
} | go | func (t *Collection) Get(key []byte) (val []byte, err error) {
i, err := t.GetItem(key, true)
if err != nil {
return nil, err
}
if i != nil {
return i.Val, nil
}
return nil, nil
} | [
"func",
"(",
"t",
"*",
"Collection",
")",
"Get",
"(",
"key",
"[",
"]",
"byte",
")",
"(",
"val",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"i",
",",
"err",
":=",
"t",
".",
"GetItem",
"(",
"key",
",",
"true",
")",
"\n",
"if",
"err",
"!... | // Retrieve a value by its key. Returns nil if the item is not in the
// collection. The returned value should be treated as immutable. | [
"Retrieve",
"a",
"value",
"by",
"its",
"key",
".",
"Returns",
"nil",
"if",
"the",
"item",
"is",
"not",
"in",
"the",
"collection",
".",
"The",
"returned",
"value",
"should",
"be",
"treated",
"as",
"immutable",
"."
] | 5b47ed6d7458f12bd18b0883b197f3e889ab9ad0 | https://github.com/steveyen/gkvlite/blob/5b47ed6d7458f12bd18b0883b197f3e889ab9ad0/collection.go#L109-L118 |
139,884 | steveyen/gkvlite | collection.go | Set | func (t *Collection) Set(key []byte, val []byte) error {
return t.SetItem(&Item{Key: key, Val: val, Priority: rand.Int31()})
} | go | func (t *Collection) Set(key []byte, val []byte) error {
return t.SetItem(&Item{Key: key, Val: val, Priority: rand.Int31()})
} | [
"func",
"(",
"t",
"*",
"Collection",
")",
"Set",
"(",
"key",
"[",
"]",
"byte",
",",
"val",
"[",
"]",
"byte",
")",
"error",
"{",
"return",
"t",
".",
"SetItem",
"(",
"&",
"Item",
"{",
"Key",
":",
"key",
",",
"Val",
":",
"val",
",",
"Priority",
... | // Replace or insert an item of a given key. | [
"Replace",
"or",
"insert",
"an",
"item",
"of",
"a",
"given",
"key",
"."
] | 5b47ed6d7458f12bd18b0883b197f3e889ab9ad0 | https://github.com/steveyen/gkvlite/blob/5b47ed6d7458f12bd18b0883b197f3e889ab9ad0/collection.go#L160-L162 |
139,885 | steveyen/gkvlite | collection.go | Delete | func (t *Collection) Delete(key []byte) (wasDeleted bool, err error) {
if t.store.readOnly {
return false, errors.New("store is read only")
}
rnl := t.rootAddRef()
defer t.rootDecRef(rnl)
root := rnl.root
i, err := t.GetItem(key, false)
if err != nil || i == nil {
return false, err
}
t.store.ItemDecRef(t, ... | go | func (t *Collection) Delete(key []byte) (wasDeleted bool, err error) {
if t.store.readOnly {
return false, errors.New("store is read only")
}
rnl := t.rootAddRef()
defer t.rootDecRef(rnl)
root := rnl.root
i, err := t.GetItem(key, false)
if err != nil || i == nil {
return false, err
}
t.store.ItemDecRef(t, ... | [
"func",
"(",
"t",
"*",
"Collection",
")",
"Delete",
"(",
"key",
"[",
"]",
"byte",
")",
"(",
"wasDeleted",
"bool",
",",
"err",
"error",
")",
"{",
"if",
"t",
".",
"store",
".",
"readOnly",
"{",
"return",
"false",
",",
"errors",
".",
"New",
"(",
"\"... | // Deletes an item of a given key. | [
"Deletes",
"an",
"item",
"of",
"a",
"given",
"key",
"."
] | 5b47ed6d7458f12bd18b0883b197f3e889ab9ad0 | https://github.com/steveyen/gkvlite/blob/5b47ed6d7458f12bd18b0883b197f3e889ab9ad0/collection.go#L165-L205 |
139,886 | steveyen/gkvlite | collection.go | MinItem | func (t *Collection) MinItem(withValue bool) (*Item, error) {
return t.store.walk(t, withValue,
func(n *node) (*nodeLoc, bool) { return &n.left, true })
} | go | func (t *Collection) MinItem(withValue bool) (*Item, error) {
return t.store.walk(t, withValue,
func(n *node) (*nodeLoc, bool) { return &n.left, true })
} | [
"func",
"(",
"t",
"*",
"Collection",
")",
"MinItem",
"(",
"withValue",
"bool",
")",
"(",
"*",
"Item",
",",
"error",
")",
"{",
"return",
"t",
".",
"store",
".",
"walk",
"(",
"t",
",",
"withValue",
",",
"func",
"(",
"n",
"*",
"node",
")",
"(",
"*... | // Retrieves the item with the "smallest" key.
// The returned item should be treated as immutable. | [
"Retrieves",
"the",
"item",
"with",
"the",
"smallest",
"key",
".",
"The",
"returned",
"item",
"should",
"be",
"treated",
"as",
"immutable",
"."
] | 5b47ed6d7458f12bd18b0883b197f3e889ab9ad0 | https://github.com/steveyen/gkvlite/blob/5b47ed6d7458f12bd18b0883b197f3e889ab9ad0/collection.go#L209-L212 |
139,887 | steveyen/gkvlite | collection.go | MaxItem | func (t *Collection) MaxItem(withValue bool) (*Item, error) {
return t.store.walk(t, withValue,
func(n *node) (*nodeLoc, bool) { return &n.right, true })
} | go | func (t *Collection) MaxItem(withValue bool) (*Item, error) {
return t.store.walk(t, withValue,
func(n *node) (*nodeLoc, bool) { return &n.right, true })
} | [
"func",
"(",
"t",
"*",
"Collection",
")",
"MaxItem",
"(",
"withValue",
"bool",
")",
"(",
"*",
"Item",
",",
"error",
")",
"{",
"return",
"t",
".",
"store",
".",
"walk",
"(",
"t",
",",
"withValue",
",",
"func",
"(",
"n",
"*",
"node",
")",
"(",
"*... | // Retrieves the item with the "largest" key.
// The returned item should be treated as immutable. | [
"Retrieves",
"the",
"item",
"with",
"the",
"largest",
"key",
".",
"The",
"returned",
"item",
"should",
"be",
"treated",
"as",
"immutable",
"."
] | 5b47ed6d7458f12bd18b0883b197f3e889ab9ad0 | https://github.com/steveyen/gkvlite/blob/5b47ed6d7458f12bd18b0883b197f3e889ab9ad0/collection.go#L216-L219 |
139,888 | steveyen/gkvlite | collection.go | VisitItemsAscend | func (t *Collection) VisitItemsAscend(target []byte, withValue bool, v ItemVisitor) error {
return t.VisitItemsAscendEx(target, withValue,
func(i *Item, depth uint64) bool { return v(i) })
} | go | func (t *Collection) VisitItemsAscend(target []byte, withValue bool, v ItemVisitor) error {
return t.VisitItemsAscendEx(target, withValue,
func(i *Item, depth uint64) bool { return v(i) })
} | [
"func",
"(",
"t",
"*",
"Collection",
")",
"VisitItemsAscend",
"(",
"target",
"[",
"]",
"byte",
",",
"withValue",
"bool",
",",
"v",
"ItemVisitor",
")",
"error",
"{",
"return",
"t",
".",
"VisitItemsAscendEx",
"(",
"target",
",",
"withValue",
",",
"func",
"... | // Visit items greater-than-or-equal to the target key in ascending order. | [
"Visit",
"items",
"greater",
"-",
"than",
"-",
"or",
"-",
"equal",
"to",
"the",
"target",
"key",
"in",
"ascending",
"order",
"."
] | 5b47ed6d7458f12bd18b0883b197f3e889ab9ad0 | https://github.com/steveyen/gkvlite/blob/5b47ed6d7458f12bd18b0883b197f3e889ab9ad0/collection.go#L256-L259 |
139,889 | steveyen/gkvlite | collection.go | VisitItemsDescend | func (t *Collection) VisitItemsDescend(target []byte, withValue bool, v ItemVisitor) error {
return t.VisitItemsDescendEx(target, withValue,
func(i *Item, depth uint64) bool { return v(i) })
} | go | func (t *Collection) VisitItemsDescend(target []byte, withValue bool, v ItemVisitor) error {
return t.VisitItemsDescendEx(target, withValue,
func(i *Item, depth uint64) bool { return v(i) })
} | [
"func",
"(",
"t",
"*",
"Collection",
")",
"VisitItemsDescend",
"(",
"target",
"[",
"]",
"byte",
",",
"withValue",
"bool",
",",
"v",
"ItemVisitor",
")",
"error",
"{",
"return",
"t",
".",
"VisitItemsDescendEx",
"(",
"target",
",",
"withValue",
",",
"func",
... | // Visit items less-than the target key in descending order. | [
"Visit",
"items",
"less",
"-",
"than",
"the",
"target",
"key",
"in",
"descending",
"order",
"."
] | 5b47ed6d7458f12bd18b0883b197f3e889ab9ad0 | https://github.com/steveyen/gkvlite/blob/5b47ed6d7458f12bd18b0883b197f3e889ab9ad0/collection.go#L262-L265 |
139,890 | steveyen/gkvlite | collection.go | VisitItemsAscendEx | func (t *Collection) VisitItemsAscendEx(target []byte, withValue bool,
visitor ItemVisitorEx) error {
rnl := t.rootAddRef()
defer t.rootDecRef(rnl)
var prevVisitItem *Item
var errCheckedVisitor error
checkedVisitor := func(i *Item, depth uint64) bool {
if prevVisitItem != nil && t.compare(prevVisitItem.Key, i... | go | func (t *Collection) VisitItemsAscendEx(target []byte, withValue bool,
visitor ItemVisitorEx) error {
rnl := t.rootAddRef()
defer t.rootDecRef(rnl)
var prevVisitItem *Item
var errCheckedVisitor error
checkedVisitor := func(i *Item, depth uint64) bool {
if prevVisitItem != nil && t.compare(prevVisitItem.Key, i... | [
"func",
"(",
"t",
"*",
"Collection",
")",
"VisitItemsAscendEx",
"(",
"target",
"[",
"]",
"byte",
",",
"withValue",
"bool",
",",
"visitor",
"ItemVisitorEx",
")",
"error",
"{",
"rnl",
":=",
"t",
".",
"rootAddRef",
"(",
")",
"\n",
"defer",
"t",
".",
"root... | // Visit items greater-than-or-equal to the target key in ascending order; with depth info. | [
"Visit",
"items",
"greater",
"-",
"than",
"-",
"or",
"-",
"equal",
"to",
"the",
"target",
"key",
"in",
"ascending",
"order",
";",
"with",
"depth",
"info",
"."
] | 5b47ed6d7458f12bd18b0883b197f3e889ab9ad0 | https://github.com/steveyen/gkvlite/blob/5b47ed6d7458f12bd18b0883b197f3e889ab9ad0/collection.go#L268-L293 |
139,891 | steveyen/gkvlite | collection.go | VisitItemsDescendEx | func (t *Collection) VisitItemsDescendEx(target []byte, withValue bool,
visitor ItemVisitorEx) error {
rnl := t.rootAddRef()
defer t.rootDecRef(rnl)
_, err := t.store.visitNodes(t, rnl.root,
target, withValue, visitor, 0, descendChoice)
return err
} | go | func (t *Collection) VisitItemsDescendEx(target []byte, withValue bool,
visitor ItemVisitorEx) error {
rnl := t.rootAddRef()
defer t.rootDecRef(rnl)
_, err := t.store.visitNodes(t, rnl.root,
target, withValue, visitor, 0, descendChoice)
return err
} | [
"func",
"(",
"t",
"*",
"Collection",
")",
"VisitItemsDescendEx",
"(",
"target",
"[",
"]",
"byte",
",",
"withValue",
"bool",
",",
"visitor",
"ItemVisitorEx",
")",
"error",
"{",
"rnl",
":=",
"t",
".",
"rootAddRef",
"(",
")",
"\n",
"defer",
"t",
".",
"roo... | // Visit items less-than the target key in descending order; with depth info. | [
"Visit",
"items",
"less",
"-",
"than",
"the",
"target",
"key",
"in",
"descending",
"order",
";",
"with",
"depth",
"info",
"."
] | 5b47ed6d7458f12bd18b0883b197f3e889ab9ad0 | https://github.com/steveyen/gkvlite/blob/5b47ed6d7458f12bd18b0883b197f3e889ab9ad0/collection.go#L296-L304 |
139,892 | steveyen/gkvlite | collection.go | GetTotals | func (t *Collection) GetTotals() (numItems uint64, numBytes uint64, err error) {
rnl := t.rootAddRef()
defer t.rootDecRef(rnl)
n := rnl.root
nNode, err := n.read(t.store)
if err != nil || n.isEmpty() || nNode == nil {
return 0, 0, err
}
return nNode.numNodes, nNode.numBytes, nil
} | go | func (t *Collection) GetTotals() (numItems uint64, numBytes uint64, err error) {
rnl := t.rootAddRef()
defer t.rootDecRef(rnl)
n := rnl.root
nNode, err := n.read(t.store)
if err != nil || n.isEmpty() || nNode == nil {
return 0, 0, err
}
return nNode.numNodes, nNode.numBytes, nil
} | [
"func",
"(",
"t",
"*",
"Collection",
")",
"GetTotals",
"(",
")",
"(",
"numItems",
"uint64",
",",
"numBytes",
"uint64",
",",
"err",
"error",
")",
"{",
"rnl",
":=",
"t",
".",
"rootAddRef",
"(",
")",
"\n",
"defer",
"t",
".",
"rootDecRef",
"(",
"rnl",
... | // Returns total number of items and total key bytes plus value bytes. | [
"Returns",
"total",
"number",
"of",
"items",
"and",
"total",
"key",
"bytes",
"plus",
"value",
"bytes",
"."
] | 5b47ed6d7458f12bd18b0883b197f3e889ab9ad0 | https://github.com/steveyen/gkvlite/blob/5b47ed6d7458f12bd18b0883b197f3e889ab9ad0/collection.go#L315-L324 |
139,893 | steveyen/gkvlite | collection.go | UnmarshalJSON | func (t *Collection) UnmarshalJSON(d []byte) error {
p := ploc{}
if err := json.Unmarshal(d, &p); err != nil {
return err
}
if t.rootLock == nil {
t.rootLock = &sync.Mutex{}
}
nloc := t.mkNodeLoc(nil)
nloc.loc = unsafe.Pointer(&p)
if !t.rootCAS(nil, t.mkRootNodeLoc(nloc)) {
return errors.New("concurrent m... | go | func (t *Collection) UnmarshalJSON(d []byte) error {
p := ploc{}
if err := json.Unmarshal(d, &p); err != nil {
return err
}
if t.rootLock == nil {
t.rootLock = &sync.Mutex{}
}
nloc := t.mkNodeLoc(nil)
nloc.loc = unsafe.Pointer(&p)
if !t.rootCAS(nil, t.mkRootNodeLoc(nloc)) {
return errors.New("concurrent m... | [
"func",
"(",
"t",
"*",
"Collection",
")",
"UnmarshalJSON",
"(",
"d",
"[",
"]",
"byte",
")",
"error",
"{",
"p",
":=",
"ploc",
"{",
"}",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"d",
",",
"&",
"p",
")",
";",
"err",
"!=",
"nil",
"... | // Unmarshals JSON representation of root node file location. | [
"Unmarshals",
"JSON",
"representation",
"of",
"root",
"node",
"file",
"location",
"."
] | 5b47ed6d7458f12bd18b0883b197f3e889ab9ad0 | https://github.com/steveyen/gkvlite/blob/5b47ed6d7458f12bd18b0883b197f3e889ab9ad0/collection.go#L343-L357 |
139,894 | steveyen/gkvlite | item.go | NumBytes | func (i *Item) NumBytes(c *Collection) int {
return len(i.Key) + i.NumValBytes(c)
} | go | func (i *Item) NumBytes(c *Collection) int {
return len(i.Key) + i.NumValBytes(c)
} | [
"func",
"(",
"i",
"*",
"Item",
")",
"NumBytes",
"(",
"c",
"*",
"Collection",
")",
"int",
"{",
"return",
"len",
"(",
"i",
".",
"Key",
")",
"+",
"i",
".",
"NumValBytes",
"(",
"c",
")",
"\n",
"}"
] | // Number of Key bytes plus number of Val bytes. | [
"Number",
"of",
"Key",
"bytes",
"plus",
"number",
"of",
"Val",
"bytes",
"."
] | 5b47ed6d7458f12bd18b0883b197f3e889ab9ad0 | https://github.com/steveyen/gkvlite/blob/5b47ed6d7458f12bd18b0883b197f3e889ab9ad0/item.go#L27-L29 |
139,895 | steveyen/gkvlite | tools/slab/slab.go | readBufChain | func readBufChain(arena *slab.Arena, maxBufSize int, r io.ReaderAt, offset int64,
valLength uint32) ([]byte, error) {
n := int(valLength)
if n > maxBufSize {
n = maxBufSize
}
b := arena.Alloc(n)
_, err := r.ReadAt(b, offset)
if err != nil {
arena.DecRef(b)
return nil, err
}
remaining := valLength - uint3... | go | func readBufChain(arena *slab.Arena, maxBufSize int, r io.ReaderAt, offset int64,
valLength uint32) ([]byte, error) {
n := int(valLength)
if n > maxBufSize {
n = maxBufSize
}
b := arena.Alloc(n)
_, err := r.ReadAt(b, offset)
if err != nil {
arena.DecRef(b)
return nil, err
}
remaining := valLength - uint3... | [
"func",
"readBufChain",
"(",
"arena",
"*",
"slab",
".",
"Arena",
",",
"maxBufSize",
"int",
",",
"r",
"io",
".",
"ReaderAt",
",",
"offset",
"int64",
",",
"valLength",
"uint32",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"n",
":=",
"int",
"(... | // Helper function to read a contiguous byte sequence, splitting
// it up into chained buf's of maxBufSize. The last buf in the
// chain can have length <= maxBufSize. | [
"Helper",
"function",
"to",
"read",
"a",
"contiguous",
"byte",
"sequence",
"splitting",
"it",
"up",
"into",
"chained",
"buf",
"s",
"of",
"maxBufSize",
".",
"The",
"last",
"buf",
"in",
"the",
"chain",
"can",
"have",
"length",
"<",
"=",
"maxBufSize",
"."
] | 5b47ed6d7458f12bd18b0883b197f3e889ab9ad0 | https://github.com/steveyen/gkvlite/blob/5b47ed6d7458f12bd18b0883b197f3e889ab9ad0/tools/slab/slab.go#L73-L95 |
139,896 | steveyen/gkvlite | store.go | GetCollection | func (s *Store) GetCollection(name string) *Collection {
coll := *(*map[string]*Collection)(atomic.LoadPointer(&s.coll))
return coll[name]
} | go | func (s *Store) GetCollection(name string) *Collection {
coll := *(*map[string]*Collection)(atomic.LoadPointer(&s.coll))
return coll[name]
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"GetCollection",
"(",
"name",
"string",
")",
"*",
"Collection",
"{",
"coll",
":=",
"*",
"(",
"*",
"map",
"[",
"string",
"]",
"*",
"Collection",
")",
"(",
"atomic",
".",
"LoadPointer",
"(",
"&",
"s",
".",
"coll",... | // Retrieves a named Collection. | [
"Retrieves",
"a",
"named",
"Collection",
"."
] | 5b47ed6d7458f12bd18b0883b197f3e889ab9ad0 | https://github.com/steveyen/gkvlite/blob/5b47ed6d7458f12bd18b0883b197f3e889ab9ad0/store.go#L151-L154 |
139,897 | steveyen/gkvlite | store.go | Stats | func (s *Store) Stats(out map[string]uint64) {
out["fileSize"] = uint64(atomic.LoadInt64(&s.size))
out["nodeAllocs"] = atomic.LoadUint64(&s.nodeAllocs)
} | go | func (s *Store) Stats(out map[string]uint64) {
out["fileSize"] = uint64(atomic.LoadInt64(&s.size))
out["nodeAllocs"] = atomic.LoadUint64(&s.nodeAllocs)
} | [
"func",
"(",
"s",
"*",
"Store",
")",
"Stats",
"(",
"out",
"map",
"[",
"string",
"]",
"uint64",
")",
"{",
"out",
"[",
"\"",
"\"",
"]",
"=",
"uint64",
"(",
"atomic",
".",
"LoadInt64",
"(",
"&",
"s",
".",
"size",
")",
")",
"\n",
"out",
"[",
"\""... | // Updates the provided map with statistics. | [
"Updates",
"the",
"provided",
"map",
"with",
"statistics",
"."
] | 5b47ed6d7458f12bd18b0883b197f3e889ab9ad0 | https://github.com/steveyen/gkvlite/blob/5b47ed6d7458f12bd18b0883b197f3e889ab9ad0/store.go#L344-L347 |
139,898 | cocoonlife/goalsa | alsa.go | Close | func (d *device) Close() {
if d.h != nil {
C.snd_pcm_drain(d.h)
C.snd_pcm_close(d.h)
d.h = nil
}
runtime.SetFinalizer(d, nil)
} | go | func (d *device) Close() {
if d.h != nil {
C.snd_pcm_drain(d.h)
C.snd_pcm_close(d.h)
d.h = nil
}
runtime.SetFinalizer(d, nil)
} | [
"func",
"(",
"d",
"*",
"device",
")",
"Close",
"(",
")",
"{",
"if",
"d",
".",
"h",
"!=",
"nil",
"{",
"C",
".",
"snd_pcm_drain",
"(",
"d",
".",
"h",
")",
"\n",
"C",
".",
"snd_pcm_close",
"(",
"d",
".",
"h",
")",
"\n",
"d",
".",
"h",
"=",
"... | // Close closes a device and frees the resources associated with it. | [
"Close",
"closes",
"a",
"device",
"and",
"frees",
"the",
"resources",
"associated",
"with",
"it",
"."
] | b711ae6f3eff1a4f0cc4edfe321ab171027f85d4 | https://github.com/cocoonlife/goalsa/blob/b711ae6f3eff1a4f0cc4edfe321ab171027f85d4/alsa.go#L159-L166 |
139,899 | cocoonlife/goalsa | alsa.go | NewCaptureDevice | func NewCaptureDevice(deviceName string, channels int, format Format, rate int, bufferParams BufferParams) (c *CaptureDevice, err error) {
c = new(CaptureDevice)
err = c.createDevice(deviceName, channels, format, rate, false, bufferParams)
if err != nil {
return nil, err
}
return c, nil
} | go | func NewCaptureDevice(deviceName string, channels int, format Format, rate int, bufferParams BufferParams) (c *CaptureDevice, err error) {
c = new(CaptureDevice)
err = c.createDevice(deviceName, channels, format, rate, false, bufferParams)
if err != nil {
return nil, err
}
return c, nil
} | [
"func",
"NewCaptureDevice",
"(",
"deviceName",
"string",
",",
"channels",
"int",
",",
"format",
"Format",
",",
"rate",
"int",
",",
"bufferParams",
"BufferParams",
")",
"(",
"c",
"*",
"CaptureDevice",
",",
"err",
"error",
")",
"{",
"c",
"=",
"new",
"(",
"... | // NewCaptureDevice creates a new CaptureDevice object. | [
"NewCaptureDevice",
"creates",
"a",
"new",
"CaptureDevice",
"object",
"."
] | b711ae6f3eff1a4f0cc4edfe321ab171027f85d4 | https://github.com/cocoonlife/goalsa/blob/b711ae6f3eff1a4f0cc4edfe321ab171027f85d4/alsa.go#L188-L195 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.