92件ヒット
[1-92件を表示]
(0.170秒)
ライブラリ
- openssl (92)
キーワード
-
clear
_ bit! (12) - coerce (12)
-
mask
_ bits! (12) -
mod
_ add (12) - negative? (8)
-
prime
_ fasttest? (12) -
set
_ bit! (12) -
to
_ s (12)
検索結果
先頭5件
-
OpenSSL
:: BN # clear _ bit!(n) -> self (6120.0) -
自身の n ビット目を0にします。
...自身の n ビット目を0にします。
//emlist[][ruby]{
require 'openssl'
a = OpenSSL::BN.new("129")
a.clear_bit!(0)
a # => 128
//}
@param n 0にするビットの位置
@raise OpenSSL::BNError 計算時エラー
@see OpenSSL::set_bit!... -
OpenSSL
:: BN # mask _ bits!(n) -> self (6102.0) -
自身を下位 n ビットでマスクし、破壊的に変更します。
...い場合は例外 OpenSSL::BNError
が発生します。
//emlist[][ruby]{
require 'openssl'
bn = 0b1111_1111.to_bn
bn.mask_bits!(8)
p "%b" % bn # => "11111111"
bn.mask_bits!(3)
p "%b" % bn # => "111"
//}
@param n マスクするビット数
@raise OpenSSL::BNError 計算時エ... -
OpenSSL
:: BN # mod _ add(other , m) -> OpenSSL :: BN (6102.0) -
(self + other) % m を返します。
...(self + other) % m を返します。
//emlist[][ruby]{
require 'openssl'
OpenSSL::BN.new("7").mod_add(OpenSSL::BN.new("3"), OpenSSL::BN.new("6")) # => 4
//}
@param other 和を取る数
@param m 剰余を取る数
@raise OpenSSL::BNError 計算時エラー... -
OpenSSL
:: BN # negative? -> bool (6102.0) -
自身が負である場合に true を返します。Ruby 2.5, OpenSSL 2.1.0 から利用できます。
...自身が負である場合に true を返します。Ruby 2.5, OpenSSL 2.1.0 から利用できます。
//emlist[][ruby]{
require 'openssl'
p 15.to_bn.negative? # => false
p 0.to_bn.negative? # => false
p (-5).to_bn.negative? # => true
//}... -
OpenSSL
:: BN # prime _ fasttest?(checks=nil , vtrivdiv=true) -> bool (6102.0) -
自身が素数であるなら true を返します。
...である場合には、 Miller-Rabin 法での
判定の前に小さな素数で割ることで素数か否かを
調べます。自身が小さな素数である場合にはこの手順
により素数ではないと誤った返り値を返します。
Miller-Rabin 法により確率的に判定......ある
OpenSSL::BN.new("181").prime_fasttest?(nil, true) # => false
OpenSSL::BN.new("181").prime_fasttest?(nil, false) # => true
//}
@param checks Miller-Robin法の繰り返しの回数
@param vtrivdiv 真なら小さな素数で割ることでの素数判定を試みます
@raise OpenSSL::BNError......判定時にエラーが発生
@see OpenSSL::BN#prime?... -
OpenSSL
:: BN # to _ s(base=10) -> String (126.0) -
自身を表す文字列を返します。
...す。
base で、変換方法(基数)を指定します。
デフォルトは 10 で、他に 16, 2, 0 を指定できます。
10 10進数の表記
16 16進数の表記
2 big-endianの符号無し整数のバイナリ列
0 MPI形式の文字列(バイト列)
@param base 文字列......換方法(基数)
@raise OpenSSL::BNError 変換に失敗した場合に発生します
//emlist[][ruby]{
require 'openssl'
p 10.to_bn.to_s # => "10"
p (-5).to_bn.to_s # => "-5"
p 0.to_bn.to_s(16) # => "0"
p 9.to_bn.to_s(16) # => "09"
p 10.to_bn.to_s(16) # => "0A"
p 16.to_bn.to_s(16) #......1A"
p 256.to_bn.to_s(16) # => "0100"
p 0.to_bn.to_s(2) # => ""
p 6.to_bn.to_s(2) # => "\x06"
p 7.to_bn.to_s(2) # => "\a"
p 0.to_bn.to_s(0) # => "\x00\x00\x00\x00"
p 6.to_bn.to_s(0) # => "\x00\x00\x00\x01\x06"
p 7.to_bn.to_s(0) # => "\x00\x00\x00\x01\a"
//}
反対に、文字列から OpenSSL::BN... -
OpenSSL
:: BN # coerce(other) -> Array (102.0) -
自身と other が同じクラスになるよう、自身か other を変換し [other, self] という配列にして返します。
...は例外 TypeError を発生させます。
//emlist[][ruby]{
require 'openssl'
p 1.to_bn.coerce(2) # => [2, 1]
//}
@param other 変換の基準となるオブジェクト
@raise TypeError 変換に失敗した場合に発生します
coerce メソッドの詳細な説明は、Numeric#coerce... -
OpenSSL
:: BN # set _ bit!(n) -> self (20.0) -
自身の n ビット目を1にします。
...自身の n ビット目を1にします。
//emlist[][ruby]{
require 'openssl'
a = OpenSSL::BN.new("128")
a.set_bit!(0)
a # => 129
//}
@param n 1にするビットの位置
@raise OpenSSL::BNError 計算時エラー
@see OpenSSL::clear_bit!, OpenSSL::bit_set?...