ncrypt-site / php-sdk
PHP SDK for ncrypt.site
Requires
- php: >=7.1
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- ext-openssl: *
- guzzlehttp/guzzle: ^6.0
Requires (Dev)
- friendsofphp/php-cs-fixer: 2.15.*
- phpunit/phpunit: ^9
- roave/security-advisories: dev-master
- squizlabs/php_codesniffer: ~2.6
This package is auto-updated.
Last update: 2024-05-12 19:44:39 UTC
README
nCrypt API documentation
This SDK allows you to use nCrypt in your application. It means you can easily create a secure note inside your application.
Swagger-CodeGen initially generated part of this SDK, and then it was modified to fit the needs, those codes will be removed in the next couple of releases as it was my idea to release the first version as soon as possible.
Requirements
PHP 7.1 and later
Installation & Usage
Composer
You can easily install nCrypt SDK via composer:
composer require ncrypt-site/php-sdk
Getting Started
After installing the SDK, you can use it as the sample below:
use NCrypt\Client\Api\NCryptAPI; use NCrypt\Client\Library\RequestBuilder\RequestBuilder; include './vendor/autoload.php'; $api = new NCryptAPI( new GuzzleHttp\Client() ); $requestBuilder = new RequestBuilder(); $request = $requestBuilder->prepareSecureNoteRequest('Your Very Secure Note', 1, false); try { $result = $api->notePost($request->getNoteRequest()); echo 'Note URL is: ' . $result->getData()->getUrl() . PHP_EOL; echo 'You can unseal the note with this key: ' . $request->getSecureNote()->getKey() . PHP_EOL; } catch (Exception $e) { echo $e->getMessage(); }
prepareSecureNoteRequest
This method accepts three arguments, just like the fields inside the website.
# | Argument | Type | Example |
---|---|---|---|
1 | $note | string | Ever have that feeling where you’re not sure if you’re awake or dreaming? |
2 | $selfDestruct | int | 1 |
3 | $destructAfterOpening | boolean | true |
$selfDestruct acceptable values:
The following numbers are acceptable values for $selfDestruct
argument, note that the values are based on hour and
will indicate how long we will store the notes on our servers.
[ 1, 3, 6, 12, 24, 48, 72, 168 ]
Issues
currently, there is no known issue, but feel free to open an issue in Github so that I can fix it ASAP.