Skip to content

Instantly share code, notes, and snippets.

@aniketp
Last active February 12, 2019 12:03
Show Gist options
  • Save aniketp/6055bc837b45f1f0bd7be574e23095de to your computer and use it in GitHub Desktop.
Save aniketp/6055bc837b45f1f0bd7be574e23095de to your computer and use it in GitHub Desktop.
Code snippet which can be used as a conversion from "filename" to "key" in key-value DataStore
type PrivateKey = userlib.PrivateKey
type User_r struct {
User struct {
Username string
Password string
Privkey PrivateKey
A2ksalt string // To be used as a salt for Argon KDF
}
Signature []byte
}
type Inode_r struct {
Inode struct {
Filename string
ShRecordAddr string
InitVector []byte
SymmKey []byte
}
Signature []byte
}
type SharingRecord_r struct {
SharingRecord struct {
Type string
MainAuthor string
Collaborators []string
Address string
SymmKey []byte
}
Signature []byte
}
type Data_r struct {
Value []byte
Signature []byte
}
func main() {
filename := []byte("akashish-randomfilename")
hash := userlib.Argon2Key(filename, []byte("akashish-password"), 10)
marsh, err := json.Marshal(hash)
if err != nil {
userlib.DebugMsg("Marshal failed")
}
marsh_string := hex.EncodeToString(marsh)
fmt.Println(marsh_string, len(marsh_string))
}
// Output:
// 2237382b74676c444777424e4d4d413d3d22 36 (Can be used as a key in key-value DataStore)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment