PHP code example of strukt / key

1. Go to this page and download the library: Download strukt/key library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

strukt / key example snippets


$hash = bcry("p@55w0rd")->encode()
$success = bcry("p@55w0rd")->verify($hash);

$hash = sha256dbl('p@55w0rd');

$k = Strukt\Ssl\All::makeKeys()
$k->getKeys()->getPrivateKey()->getPem()//get private key
$k->getKeys()->getPublicKey()->getPem()//get public key
$c = $k->useCipher()
$enc = $c->encrypt("p@55w0rd")
$dec = $c->decrypt($enc)

$file = "file:///home/churchill/.ssh/id_rsa"
$k = Strukt\Ssl\All::keyPath($file)

$message = "Hi! My name is (what?)
My name is (who?)
My name is
Slim Shady
Hi! My name is (huh?)
My name is (what?)
My name is
Slim Shady";

$file = "file:///home/churchill/.ssh/id_rsa.pub"

$p = new Strukt\Ssl\KeyPair();//No private key
$p->setPublicKey($file);

$enc = Strukt\Ssl\All::useKeys($p)->toSend($message);

$p = new Strukt\Ssl\KeyPair($path, "p@55w0rd");
$p->getPublicKey()//trigger public key extraction from private key

$k = Strukt\Ssl\All::useKeys($p)

$kpath = "file:///home/churchill/.ssh/id_rsa"
$cpath = "file:///home/churchill/.ssh/cacert.pem"

$oCsr = Strukt\Ssl\All::keyPath($kpath)->withCert($cpath);

$cert = $oCsr->sign();

$success = $oCsr->verify($cert);