Add last night's progress.
Basic functionality for HOTP, TOTP, and YubiKey OTP. Still need YubiKey HMAC, serialisation, check, and scan.
This commit is contained in:
29
modhex/example_test.go
Normal file
29
modhex/example_test.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package modhex
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gokyle/twofactor/modhex"
|
||||
)
|
||||
|
||||
var out = "fjhghrhrhvdrdciihvidhrhfdb"
|
||||
var in = "Hello, world!"
|
||||
|
||||
func ExampleEncoding_EncodeToString() {
|
||||
data := []byte("Hello, world!")
|
||||
str := modhex.StdEncoding.EncodeToString(data)
|
||||
fmt.Println(str)
|
||||
// Output:
|
||||
// fjhghrhrhvdrdciihvidhrhfdb
|
||||
}
|
||||
|
||||
func ExampleEncoding_DecodeString() {
|
||||
str := "fjhghrhrhvdrdciihvidhrhfdb"
|
||||
data, err := modhex.StdEncoding.DecodeString(str)
|
||||
if err != nil {
|
||||
fmt.Printf("%v\n", err)
|
||||
return
|
||||
}
|
||||
fmt.Printf("%s", string(data))
|
||||
// Output:
|
||||
// Hello, world!
|
||||
}
|
||||
Reference in New Issue
Block a user