ParagonIE\Halite\KeyFactory::export PHP Method

export() public static method

Export a cryptography key to a string (with a checksum)
public static export ( $key ) : HiddenString
$key
return HiddenString
    public static function export($key) : HiddenString
    {
        if ($key instanceof KeyPair) {
            return self::export($key->getSecretKey());
        }
        if ($key instanceof Key) {
            return new HiddenString(\Sodium\bin2hex(Halite::HALITE_VERSION_KEYS . $key->getRawKeyMaterial() . \Sodium\crypto_generichash(Halite::HALITE_VERSION_KEYS . $key->getRawKeyMaterial(), '', \Sodium\CRYPTO_GENERICHASH_BYTES_MAX)));
        }
        throw new \TypeError('Expected a Key.');
    }