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:
Dima 2018-02-20 17:00:59 +03:00 committed by GitHub
parent 668fd8117c
commit 65fe1184a8

View File

@ -20,6 +20,7 @@ package fluence.crypto
import fluence.crypto.keypair.KeyPair
import io.circe.{ Decoder, Encoder, HCursor, Json }
import scodec.bits.{ Bases, ByteVector }
import io.circe.parser.decode
import scala.language.higherKinds
@ -54,4 +55,17 @@ object KeyStore {
} 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)
}
}
}