zoukankan      html  css  js  c++  java
  • php中openssl_encrypt方法

    openssl_encrypt( string $data, string $method, string $key[, int $options = 0[, string $iv = ""[, string &$tag = NULL[, string $aad = ""[, int $tag_length = 16]]]]] ) : string
    

     参数:

    data

    待加密的明文信息数据。

    method

    密码学方式。openssl_get_cipher_methods() 可获取有效密码方式列表。

    key

    key。

    options

    options 是以下标记的按位或: OPENSSL_RAW_DATAOPENSSL_ZERO_PADDING

    iv

    非 NULL 的初始化向量。

    tag

    使用 AEAD 密码模式(GCM 或 CCM)时传引用的验证标签。

    aad

    附加的验证数据。

    tag_length

    验证 tag 的长度。GCM 模式时,它的范围是 4 到 16。

     

    先用openssl_get_cipher_methods()方法获取有效密码方式列表:

    class Sm{
    
        /**
        * 加密
        * @return [type] [description]
        */
        public static function encrypt()
        {
            $pal = openssl_get_cipher_methods();
            return $pal;
        }
        
        /**
         * 解密
         * @return [type] [description]
         */
        public static function decode()
        {
    
        }
    
    
    }
    
    $str = "{"orderMainId":"121212121212","phone":"15168334567","type":"1","time":"20200101"}";
    $OB = new Sm();
    // $res = $OB -> getPayUrl(['tel'=>'18337168251','money'=>30], '127.0.0.1');
    $res = Sm::encrypt();
    echo '<pre>';
    var_dump($res);
    echo '<pre>';
    

     结果:

    array(176) {
      [0]=>
      string(11) "AES-128-CBC"
      [1]=>
      string(21) "AES-128-CBC-HMAC-SHA1"
      [2]=>
      string(11) "AES-128-CFB"
      [3]=>
      string(12) "AES-128-CFB1"
      [4]=>
      string(12) "AES-128-CFB8"
      [5]=>
      string(11) "AES-128-CTR"
      [6]=>
      string(11) "AES-128-ECB"
      [7]=>
      string(11) "AES-128-OFB"
      [8]=>
      string(11) "AES-128-XTS"
      [9]=>
      string(11) "AES-192-CBC"
      [10]=>
      string(11) "AES-192-CFB"
      [11]=>
      string(12) "AES-192-CFB1"
      [12]=>
      string(12) "AES-192-CFB8"
      [13]=>
      string(11) "AES-192-CTR"
      [14]=>
      string(11) "AES-192-ECB"
      [15]=>
      string(11) "AES-192-OFB"
      [16]=>
      string(11) "AES-256-CBC"
      [17]=>
      string(21) "AES-256-CBC-HMAC-SHA1"
      [18]=>
      string(11) "AES-256-CFB"
      [19]=>
      string(12) "AES-256-CFB1"
      [20]=>
      string(12) "AES-256-CFB8"
      [21]=>
      string(11) "AES-256-CTR"
      [22]=>
      string(11) "AES-256-ECB"
      [23]=>
      string(11) "AES-256-OFB"
      [24]=>
      string(11) "AES-256-XTS"
      [25]=>
      string(6) "BF-CBC"
      [26]=>
      string(6) "BF-CFB"
      [27]=>
      string(6) "BF-ECB"
      [28]=>
      string(6) "BF-OFB"
      [29]=>
      string(16) "CAMELLIA-128-CBC"
      [30]=>
      string(16) "CAMELLIA-128-CFB"
      [31]=>
      string(17) "CAMELLIA-128-CFB1"
      [32]=>
      string(17) "CAMELLIA-128-CFB8"
      [33]=>
      string(16) "CAMELLIA-128-ECB"
      [34]=>
      string(16) "CAMELLIA-128-OFB"
      [35]=>
      string(16) "CAMELLIA-192-CBC"
      [36]=>
      string(16) "CAMELLIA-192-CFB"
      [37]=>
      string(17) "CAMELLIA-192-CFB1"
      [38]=>
      string(17) "CAMELLIA-192-CFB8"
      [39]=>
      string(16) "CAMELLIA-192-ECB"
      [40]=>
      string(16) "CAMELLIA-192-OFB"
      [41]=>
      string(16) "CAMELLIA-256-CBC"
      [42]=>
      string(16) "CAMELLIA-256-CFB"
      [43]=>
      string(17) "CAMELLIA-256-CFB1"
      [44]=>
      string(17) "CAMELLIA-256-CFB8"
      [45]=>
      string(16) "CAMELLIA-256-ECB"
      [46]=>
      string(16) "CAMELLIA-256-OFB"
      [47]=>
      string(9) "CAST5-CBC"
      [48]=>
      string(9) "CAST5-CFB"
      [49]=>
      string(9) "CAST5-ECB"
      [50]=>
      string(9) "CAST5-OFB"
      [51]=>
      string(7) "DES-CBC"
      [52]=>
      string(7) "DES-CFB"
      [53]=>
      string(8) "DES-CFB1"
      [54]=>
      string(8) "DES-CFB8"
      [55]=>
      string(7) "DES-ECB"
      [56]=>
      string(7) "DES-EDE"
      [57]=>
      string(11) "DES-EDE-CBC"
      [58]=>
      string(11) "DES-EDE-CFB"
      [59]=>
      string(11) "DES-EDE-OFB"
      [60]=>
      string(8) "DES-EDE3"
      [61]=>
      string(12) "DES-EDE3-CBC"
      [62]=>
      string(12) "DES-EDE3-CFB"
      [63]=>
      string(13) "DES-EDE3-CFB1"
      [64]=>
      string(13) "DES-EDE3-CFB8"
      [65]=>
      string(12) "DES-EDE3-OFB"
      [66]=>
      string(7) "DES-OFB"
      [67]=>
      string(8) "DESX-CBC"
      [68]=>
      string(8) "IDEA-CBC"
      [69]=>
      string(8) "IDEA-CFB"
      [70]=>
      string(8) "IDEA-ECB"
      [71]=>
      string(8) "IDEA-OFB"
      [72]=>
      string(10) "RC2-40-CBC"
      [73]=>
      string(10) "RC2-64-CBC"
      [74]=>
      string(7) "RC2-CBC"
      [75]=>
      string(7) "RC2-CFB"
      [76]=>
      string(7) "RC2-ECB"
      [77]=>
      string(7) "RC2-OFB"
      [78]=>
      string(3) "RC4"
      [79]=>
      string(6) "RC4-40"
      [80]=>
      string(12) "RC4-HMAC-MD5"
      [81]=>
      string(8) "SEED-CBC"
      [82]=>
      string(8) "SEED-CFB"
      [83]=>
      string(8) "SEED-ECB"
      [84]=>
      string(8) "SEED-OFB"
      [85]=>
      string(11) "aes-128-cbc"
      [86]=>
      string(21) "aes-128-cbc-hmac-sha1"
      [87]=>
      string(11) "aes-128-cfb"
      [88]=>
      string(12) "aes-128-cfb1"
      [89]=>
      string(12) "aes-128-cfb8"
      [90]=>
      string(11) "aes-128-ctr"
      [91]=>
      string(11) "aes-128-ecb"
      [92]=>
      string(11) "aes-128-gcm"
      [93]=>
      string(11) "aes-128-ofb"
      [94]=>
      string(11) "aes-128-xts"
      [95]=>
      string(11) "aes-192-cbc"
      [96]=>
      string(11) "aes-192-cfb"
      [97]=>
      string(12) "aes-192-cfb1"
      [98]=>
      string(12) "aes-192-cfb8"
      [99]=>
      string(11) "aes-192-ctr"
      [100]=>
      string(11) "aes-192-ecb"
      [101]=>
      string(11) "aes-192-gcm"
      [102]=>
      string(11) "aes-192-ofb"
      [103]=>
      string(11) "aes-256-cbc"
      [104]=>
      string(21) "aes-256-cbc-hmac-sha1"
      [105]=>
      string(11) "aes-256-cfb"
      [106]=>
      string(12) "aes-256-cfb1"
      [107]=>
      string(12) "aes-256-cfb8"
      [108]=>
      string(11) "aes-256-ctr"
      [109]=>
      string(11) "aes-256-ecb"
      [110]=>
      string(11) "aes-256-gcm"
      [111]=>
      string(11) "aes-256-ofb"
      [112]=>
      string(11) "aes-256-xts"
      [113]=>
      string(6) "bf-cbc"
      [114]=>
      string(6) "bf-cfb"
      [115]=>
      string(6) "bf-ecb"
      [116]=>
      string(6) "bf-ofb"
      [117]=>
      string(16) "camellia-128-cbc"
      [118]=>
      string(16) "camellia-128-cfb"
      [119]=>
      string(17) "camellia-128-cfb1"
      [120]=>
      string(17) "camellia-128-cfb8"
      [121]=>
      string(16) "camellia-128-ecb"
      [122]=>
      string(16) "camellia-128-ofb"
      [123]=>
      string(16) "camellia-192-cbc"
      [124]=>
      string(16) "camellia-192-cfb"
      [125]=>
      string(17) "camellia-192-cfb1"
      [126]=>
      string(17) "camellia-192-cfb8"
      [127]=>
      string(16) "camellia-192-ecb"
      [128]=>
      string(16) "camellia-192-ofb"
      [129]=>
      string(16) "camellia-256-cbc"
      [130]=>
      string(16) "camellia-256-cfb"
      [131]=>
      string(17) "camellia-256-cfb1"
      [132]=>
      string(17) "camellia-256-cfb8"
      [133]=>
      string(16) "camellia-256-ecb"
      [134]=>
      string(16) "camellia-256-ofb"
      [135]=>
      string(9) "cast5-cbc"
      [136]=>
      string(9) "cast5-cfb"
      [137]=>
      string(9) "cast5-ecb"
      [138]=>
      string(9) "cast5-ofb"
      [139]=>
      string(7) "des-cbc"
      [140]=>
      string(7) "des-cfb"
      [141]=>
      string(8) "des-cfb1"
      [142]=>
      string(8) "des-cfb8"
      [143]=>
      string(7) "des-ecb"
      [144]=>
      string(7) "des-ede"
      [145]=>
      string(11) "des-ede-cbc"
      [146]=>
      string(11) "des-ede-cfb"
      [147]=>
      string(11) "des-ede-ofb"
      [148]=>
      string(8) "des-ede3"
      [149]=>
      string(12) "des-ede3-cbc"
      [150]=>
      string(12) "des-ede3-cfb"
      [151]=>
      string(13) "des-ede3-cfb1"
      [152]=>
      string(13) "des-ede3-cfb8"
      [153]=>
      string(12) "des-ede3-ofb"
      [154]=>
      string(7) "des-ofb"
      [155]=>
      string(8) "desx-cbc"
      [156]=>
      string(13) "id-aes128-GCM"
      [157]=>
      string(13) "id-aes192-GCM"
      [158]=>
      string(13) "id-aes256-GCM"
      [159]=>
      string(8) "idea-cbc"
      [160]=>
      string(8) "idea-cfb"
      [161]=>
      string(8) "idea-ecb"
      [162]=>
      string(8) "idea-ofb"
      [163]=>
      string(10) "rc2-40-cbc"
      [164]=>
      string(10) "rc2-64-cbc"
      [165]=>
      string(7) "rc2-cbc"
      [166]=>
      string(7) "rc2-cfb"
      [167]=>
      string(7) "rc2-ecb"
      [168]=>
      string(7) "rc2-ofb"
      [169]=>
      string(3) "rc4"
      [170]=>
      string(6) "rc4-40"
      [171]=>
      string(12) "rc4-hmac-md5"
      [172]=>
      string(8) "seed-cbc"
      [173]=>
      string(8) "seed-cfb"
      [174]=>
      string(8) "seed-ecb"
      [175]=>
      string(8) "seed-ofb"
    }
  • 相关阅读:
    SharePoint开发
    SharePoint开发
    win32-如何识别哪个静态控件被点击
    win32
    win32-创建透明的图片按钮
    读取位图文件
    python--获得特定程序的屏幕截图并保存为文件
    win32--GetFileAttributes
    谈一下交换值之后并不能返回预料的结果
    链表--insert
  • 原文地址:https://www.cnblogs.com/keketoloveme/p/15047473.html
Copyright © 2011-2022 走看看