PHP code example of hlf_513 / dingtalk-crypto

1. Go to this page and download the library: Download hlf_513/dingtalk-crypto 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/ */

    

hlf_513 / dingtalk-crypto example snippets


$crypto = new Crypto(
    $token,
    $encodingAesKey,
    $suiteKey
);

$string = 'success';
$timestamp = '1515664989185';
$nonce = '53IP1CdM';

// 加密
$ret = $crypto->encryptMsg($string, $timestamp, $nonce);
$ret = json_decode($ret, 1);
// 解密
$ret = $crypto->decryptMsg($ret['msg_signature'], $timestamp, $nonce, $ret['encrypt']);
// output: $ret === 'success'