本文簡要介紹ruby語言中 OpenSSL::PKey::DH.generate_key!
的用法。
用法
generate_key! → self
生成私鑰和公鑰,除非私鑰已存在。如果此 DH
實例是根據公共 DH 參數生成的(例如,通過對 DH#public_key
的結果進行編碼),則需要首先調用此方法,以便在執行實際 key 交換之前生成每會話 key 。
在 3.0 版中已棄用。此方法與 OpenSSL
3.0.0 或更高版本不兼容。
另見 OpenSSL::PKey.generate_key
。
例子:
# DEPRECATED USAGE: This will not work on OpenSSL 3.0 or later
dh0 = OpenSSL::PKey::DH.new(2048)
dh = dh0.public_key # #public_key only copies the DH parameters (contrary to the name)
dh.generate_key!
puts dh.private? # => true
puts dh0.pub_key == dh.pub_key #=> false
# With OpenSSL::PKey.generate_key
dh0 = OpenSSL::PKey::DH.new(2048)
dh = OpenSSL::PKey.generate_key(dh0)
puts dh0.pub_key == dh.pub_key #=> false
相關用法
- Ruby DH.public_key用法及代碼示例
- Ruby DH.new用法及代碼示例
- Ruby DH類用法及代碼示例
- Ruby Date.valid_civil?用法及代碼示例
- Ruby DateTime jisx0301()用法及代碼示例
- Ruby Date cwday()用法及代碼示例
- Ruby Date ctime()用法及代碼示例
- Ruby Date.gregorian?用法及代碼示例
- Ruby DRb.regist_server用法及代碼示例
- Ruby Date asctime()用法及代碼示例
- Ruby DateTime類用法及代碼示例
- Ruby DateTime.hour用法及代碼示例
- Ruby DateTime.jd用法及代碼示例
- Ruby DateTime.zone用法及代碼示例
- Ruby DateTime ordinal()用法及代碼示例
- Ruby DateTime.second用法及代碼示例
- Ruby Date.strftime用法及代碼示例
- Ruby Digest.update用法及代碼示例
- Ruby DSA.export用法及代碼示例
- Ruby DSA.to_pem用法及代碼示例
- Ruby DNS.new用法及代碼示例
- Ruby Document.new用法及代碼示例
- Ruby Date.valid_ordinal?用法及代碼示例
- Ruby DateTime to_datetime()用法及代碼示例
- Ruby DateTime civil()用法及代碼示例
注:本文由純淨天空篩選整理自ruby-lang.org大神的英文原創作品 DH.generate_key!。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。