Commit 4eb2be8d authored by David Stainton's avatar David Stainton

java: add wrapper function for key decoding

parent d2e757f3
......@@ -18,6 +18,8 @@
package client
import (
"encoding/hex"
"github.com/katzenpost/core/crypto/ecdh"
"github.com/katzenpost/core/crypto/rand"
)
......@@ -37,3 +39,22 @@ func GenKey() (*Key, error) {
}
return mKey, err
}
// StringToKey builds a Key from a string
func KeyFromString(keyStr string) (*Key, error) {
var key ecdh.PrivateKey
keyBytes, err := hex.DecodeString(keyStr)
if err != nil {
return &Key{}, err
}
err = key.FromBytes(keyBytes)
if err != nil {
return &Key{}, err
}
k := Key{
priv: &key,
}
return &k, nil
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment