Skip to content

Commit

Permalink
Add example to compute opc
Browse files Browse the repository at this point in the history
  • Loading branch information
wmnsk committed Jun 7, 2022
1 parent 0e6632c commit 1932422
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions examples/compute_opc/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package main

import (
"encoding/hex"
"flag"
"fmt"
"log"

"github.com/wmnsk/milenage"
)

func main() {
var (
ks = flag.String("k", "00112233445566778899aabbccddeeff", "K in hex string")
ops = flag.String("op", "00112233445566778899aabbccddeeff", "OP in hex string")
)
flag.Parse()

k, err := hex.DecodeString(*ks)
if err != nil {
log.Fatalf("Invalid K \"%s\": %+v", *ks, err)
}
op, err := hex.DecodeString(*ops)
if err != nil {
log.Fatalf("Invalid OP \"%s\": %+v", *ops, err)
}

opc, err := milenage.ComputeOPc(k, op)
if err != nil {
log.Fatalf("Failed to compute: %+v", err)
}

fmt.Printf("%x\n", opc)
}

0 comments on commit 1932422

Please sign in to comment.