mirror of
https://github.com/fluencelabs/crypto
synced 2025-04-25 06:42:19 +00:00
Client cli (#59)
* add scopts and args for start cli, parse command line with fastparse, put and get string values on remote node * refactoring * test for parser and comments * add main class * seed -> seeds * headers, PR fixes
This commit is contained in:
parent
668fd8117c
commit
65fe1184a8
@ -20,6 +20,7 @@ package fluence.crypto
|
|||||||
import fluence.crypto.keypair.KeyPair
|
import fluence.crypto.keypair.KeyPair
|
||||||
import io.circe.{ Decoder, Encoder, HCursor, Json }
|
import io.circe.{ Decoder, Encoder, HCursor, Json }
|
||||||
import scodec.bits.{ Bases, ByteVector }
|
import scodec.bits.{ Bases, ByteVector }
|
||||||
|
import io.circe.parser.decode
|
||||||
|
|
||||||
import scala.language.higherKinds
|
import scala.language.higherKinds
|
||||||
|
|
||||||
@ -54,4 +55,17 @@ object KeyStore {
|
|||||||
} yield KeyStore(KeyPair.fromByteVectors(public, secret))
|
} yield KeyStore(KeyPair.fromByteVectors(public, secret))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def fromBase64(base64: String): KeyStore = {
|
||||||
|
val jsonStr = ByteVector.fromBase64(base64, alphabet) match {
|
||||||
|
case Some(bv) ⇒ new String(bv.toArray)
|
||||||
|
case None ⇒
|
||||||
|
throw new IllegalArgumentException("'" + base64 + "' is not a valid base64.")
|
||||||
|
}
|
||||||
|
decode[Option[KeyStore]](jsonStr) match {
|
||||||
|
case Right(Some(ks)) ⇒ ks
|
||||||
|
case Right(None) ⇒ throw new IllegalArgumentException("'" + base64 + "' is not a valid key store.")
|
||||||
|
case Left(err) ⇒ throw new IllegalArgumentException("'" + base64 + "' is not a valid key store.", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user