1. php版本接入样例


##加密 AES-256-CBC

public function getEncryptApi($params, $appKey) {
    $plaintext = json_encode($params);
    $string_key = md5($appKey);
    $iv = substr($string_key, 0, 16);
    $newString = openssl_encrypt($plaintext, 'AES-256-CBC', $appKey, false, $iv);
    $content = base64_encode($newString);
    return $content;
}

##解密 AES-256-CBC

public function getDecryptApi($decrypt_string, $appKey) {
    $plaintext = base64_decode($decrypt_string);
    $string_key = md5($appKey);
    $iv = substr($string_key, 0, 16);
    $newString = openssl_decrypt($plaintext, 'AES-256-CBC', $appKey, false, $iv);
    $content_arr = json_decode($newString,true);
    return $content_arr;
}

##加密调用 getEncryptApi;解密调用getDecryptApi
@Copyright © cosmos 2019 all right reserved,powered by Gitbook修订时间: 2019-12-16 11:48:47

results matching ""

    No results matching ""