-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpractice_needed_topic.go
More file actions
76 lines (52 loc) · 1.3 KB
/
practice_needed_topic.go
File metadata and controls
76 lines (52 loc) · 1.3 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package main
/*
1. network interface card --> NIC
2. socket received buffer
3. write buffer
3. electronic magnify
4. file descriptor --> 0 < 1, 2, 3, 4...........
6. router - wifi adaptar - NIC - write buffer - interapct kurnel - copy write buffer and all thing is stored in socket received buffer
send buffer kurnel niye read buffer ar kase dai
NIC electromagnatic kore router ar kase patai
entity gulai muloto resourse hoy
*/
import (
"crypto/hmac"
"crypto/sha256"
"encoding/base64"
"fmt"
"github.com/gowaliullah/basic-ecommerce/util"
)
func practice_needed_topic() {
var s string
s = "0h"
byteArr := []byte(s)
fmt.Println(s)
fmt.Println(byteArr)
enc := base64.URLEncoding.WithPadding(base64.NoPadding)
b64Str := enc.EncodeToString(byteArr)
fmt.Println(b64Str)
// ============ //
data := []byte("Hello")
hash := sha256.Sum256(data)
fmt.Println(hash)
secret := []byte("my-secret")
message := []byte("Hello World")
h := hmac.New(sha256.New, secret)
h.Write(message)
text := h.Sum(nil)
fmt.Println(text)
// ============ //
jwt, err := util.CreateJWT("my-secret", util.Payload{
Sub: 45,
FirstName: "Habiba",
LastName: "akar",
Email: "habiba@gmail.com",
IsShopOwner: false,
})
if err != nil {
fmt.Println(err)
return
}
fmt.Println(jwt)
}