161件ヒット
[1-100件を表示]
(0.172秒)
別のキーワード
種類
- インスタンスメソッド (128)
- 特異メソッド (33)
ライブラリ
- openssl (161)
クラス
- Integer (11)
-
OpenSSL
:: BN (150)
キーワード
- << (11)
- >> (11)
- coerce (11)
- lshift! (11)
-
mask
_ bits! (11) -
mod
_ inverse (11) - negative? (7)
- new (33)
-
num
_ bytes (11) -
pretty
_ print (11) - rshift! (11)
-
to
_ s (11)
検索結果
先頭5件
-
Integer
# to _ bn -> OpenSSL :: BN (21337.0) -
Integer を同じ数を表す OpenSSL::BN のオブジェクトに 変換します。
...Integer を同じ数を表す OpenSSL::BN のオブジェクトに
変換します。
//emlist[][ruby]{
require 'pp'
require 'openssl'
pp 5.to_bn #=> #<OpenSSL::BN 5>
pp (-5).to_bn #=> #<OpenSSL::BN -5>
//}
なお、実装は、以下のようになっています。
//emlist[][ruby]{
clas......s Integer
def to_bn
OpenSSL::BN::new(self)
end
end
//}
@see OpenSSL::BN.new, OpenSSL::BN#to_i......nteger を同じ数を表す OpenSSL::BN のオブジェクトに
変換します。
//emlist[][ruby]{
require 'openssl'
pp 5.to_bn #=> #<OpenSSL::BN 5>
pp (-5).to_bn #=> #<OpenSSL::BN -5>
//}
なお、実装は、以下のようになっています。
//emlist[][ruby]{
class Integer
def......to_bn
OpenSSL::BN::new(self)
end
end
//}
@see OpenSSL::BN.new, OpenSSL::BN#to_i... -
OpenSSL
:: BN # coerce(other) -> Array (6312.0) -
自身と other が同じクラスになるよう、自身か other を変換し [other, self] という配列にして返します。
...自身と other が同じクラスになるよう、自身か other を変換し
[other, self] という配列にして返します。
基本的に other が整数のときに、自身を Integer のオブジェクトに
変換して [other, 変換後オブジェクト] にして返します。
そ......外 TypeError を発生させます。
//emlist[][ruby]{
require 'openssl'
p 1.to_bn.coerce(2) # => [2, 1]
//}
@param other 変換の基準となるオブジェクト
@raise TypeError 変換に失敗した場合に発生します
coerce メソッドの詳細な説明は、Numeric#coerce にあ......ります。
@see Numeric#coerce... -
OpenSSL
:: BN # negative? -> bool (6240.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 . new(str , base=10) -> OpenSSL :: BN (6237.0) -
文字列を多倍長整数オブジェクト(OpenSSL::BN)を生成します。
...文字列を多倍長整数オブジェクト(OpenSSL::BN)を生成します。
base で、変換方法(基数)を指定します。
デフォルトは 10 で、他に 16, 2, 0 を指定できます。
10 引数の文字列を 10進数とみなして、変換します。
16 引数の文字......します。
2 引数の文字列を big-endian の符号無し整数のバイナリ列とみなして、変換します。
0 引数の文字列を MPI形式の文字列(バイト列)とみなして、変換します。
(最初の4byteはbig-endianでデータ長を表わし、その......列(big-endian)で数値を表す。最上位ビットが立っていると負数)。
//emlist[][ruby]{
require 'openssl'
OpenSSL::BN.new("-241") # => -241
OpenSSL::BN.new("ff00",16) # => 65280
OpenSSL::BN.new("\x81",2) # => 129
OpenSSL::BN.new("\xff\x81",2) # => 65409
OpenSSL::BN.new("\x00\x0... -
OpenSSL
:: BN # num _ bytes -> Integer (6236.0) -
自身を表現するのに使っているバイト数を返します。
...自身を表現するのに使っているバイト数を返します。
//emlist[][ruby]{
require 'openssl'
p 0.to_bn.num_bytes # => 0
p 255.to_bn.num_bytes # => 1
p 256.to_bn.num_bytes # => 2
p 0b111_11111.to_bn.num_bytes # => 1
p 0b1000_00000.to_bn.num_bytes # => 2
//}... -
OpenSSL
:: BN # mod _ inverse(m) -> OpenSSL :: BN (6212.0) -
自身の mod m における逆元を返します。
...ます。
(self * r) % m == 1 となる r を返します。
存在しない場合は例外 OpenSSL::BNError が発生します。
//emlist[][ruby]{
require 'openssl'
p 3.to_bn.mod_inverse(5) # => 2
p (3 * 2) % 5 # => 1
//}
@param m mod を取る数
@raise OpenSSL::BNError 計算時... -
OpenSSL
:: BN . new(integer) -> OpenSSL :: BN (6212.0) -
整数オブジェクト(Integer)から多倍長整数オブジェクト (OpenSSL::BN)を生成します。
...整数オブジェクト(Integer)から多倍長整数オブジェクト
(OpenSSL::BN)を生成します。
@param integer 整数オブジェクト
@see Integer#to_bn... -
OpenSSL
:: BN . new(bn) -> OpenSSL :: BN (6207.0) -
OpenSSL::BN を複製して返します。
...OpenSSL::BN を複製して返します。
@param bn 複製する OpenSSL::BN オブジェクト... -
OpenSSL
:: BN # pretty _ print(pp) (6124.0) -
Kernel.#pp でオブジェクトの内容を出力するときに、内部で呼ばれるメソッドです。
...Kernel.#pp でオブジェクトの内容を出力するときに、内部で呼ばれるメソッドです。
//emlist[][ruby]{
require 'pp'
require 'openssl'
pp 5.to_bn #=> #<OpenSSL::BN 5>
pp (-5).to_bn #=> #<OpenSSL::BN -5>
//}
@param pp PP クラスのインスタンスオブジェク......Kernel.#pp でオブジェクトの内容を出力するときに、内部で呼ばれるメソッドです。
//emlist[][ruby]{
require 'openssl'
pp 5.to_bn #=> #<OpenSSL::BN 5>
pp (-5).to_bn #=> #<OpenSSL::BN -5>
//}
@param pp PP クラスのインスタンスオブジェクト... -
OpenSSL
:: BN # to _ s(base=10) -> String (3296.0) -
自身を表す文字列を返します。
...す。
base で、変換方法(基数)を指定します。
デフォルトは 10 で、他に 16, 2, 0 を指定できます。
10 10進数の表記
16 16進数の表記
2 big-endianの符号無し整数のバイナリ列
0 MPI形式の文字列(バイト列)
@param base 文字列......ise 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) # => "10"
p 26.to_bn.t......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...