This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getHOTPToken(secret string, interval int64) string { | |
//Converts secret to base32 Encoding. Base32 encoding desires a 32-character | |
//subset of the twenty-six letters A–Z and ten digits 0–9 | |
key, err := base32.StdEncoding.DecodeString(strings.ToUpper(secret)) | |
check(err) | |
bs := make([]byte, 8) | |
binary.BigEndian.PutUint64(bs, uint64(interval)) | |
//Signing the value using HMAC-SHA1 Algorithm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Checkout the readme for this here: https://github.com/tilaklodha/google-authenticator | |
package main | |
import ( | |
"bytes" | |
"crypto/hmac" | |
"crypto/sha1" | |
"encoding/base32" | |
"encoding/binary" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
ch := make(chan int, 2) | |
ch <- 5 | |
ch <- 6 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func EvenNumbersTillEight(even chan int) { | |
i := 2 | |
for i < 9 { | |
even <- i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func print(ch chan bool) { | |
fmt.Println("Printing from goroutine") | |
ch <- true | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func printnumbers() { | |
for i := 1; i <= 5; i++ { | |
time.Sleep(250 * time.Millisecond) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func print() { | |
fmt.Println("Printing from goroutine") | |
} |