Function SecretKey.fromString

static SecretKey fromString (
  scope const(char)[] str
) @safe;

Parameters

NameDescription
str the string which should contain the seed

Returns

a SecretKey from from Stellar's string representation

Throws

an Exception if the input string is not well-formed

Example

immutable seed_str = `SBBUWIMSX5VL4KVFKY44GF6Q6R5LS2Z5B7CTAZBNCNPLS4UKFVDXC7TQ`;
SecretKey seed = SecretKey.fromString(seed_str);
assert(seed.toString(PrintMode.Clear) == seed_str);
assertThrown(SecretKey.fromString(  // bad length
    "SBBUWIMSX5VL4KVFKY44GF6Q6R5LS2Z5B7CTAZBNCNPLS4UKFVDXC7T"));
assertThrown(SecretKey.fromString(  // bad version byte
    "XBBUWIMSX5VL4KVFKY44GF6Q6R5LS2Z5B7CTAZBNCNPLS4UKFVDXC7TQ"));
assertThrown(SecretKey.fromString(  // bad checksum
    "SBBUWIMSX5VL4KVFKY44GF6Q6R5LS2Z5B7CTAZBNCNPLS4UKFVDXC7TT"));
}