-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
48 lines (39 loc) · 987 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"fmt"
"github.com/aniketp/key-value-file-share/assn1"
"github.com/google/uuid"
)
// Helper function: Takes the first 16 bytes and
// converts it into the UUID type
func bytesToUUID(data []byte) (ret uuid.UUID) {
for x := range ret {
ret[x] = data[x]
}
return
}
// All the structs to be used in the assignment
func main() {
// InitUser
user1, err := assn1.InitUser("aniket", "password1")
if err != nil {
fmt.Println(err.Error())
}
user2, err := assn1.InitUser("ashish", "password2")
if err != nil {
fmt.Println(err.Error())
}
fmt.Println(user1, user2)
// GetUser (Try to ruin user data)
aniketKey := assn1.GetUserKey("aniket", "password1")
aniketCnt, _ := assn1.GetMapContent(aniketKey)
// fmt.Println(aniketCnt)
aniketCnt[len(aniketCnt)/2] = []byte("k")[0]
assn1.SetMapContent(aniketKey, aniketCnt)
user1, err = assn1.GetUser("aniket", "password1")
if err != nil {
fmt.Println(err.Error())
} else {
fmt.Println(user1)
}
}