Ruby 1.9.2 リファレンスマニュアル > ライブラリ一覧 > opensslライブラリ > OpenSSL::BNクラス

class OpenSSL::BN

クラスの継承リスト: OpenSSL::BN < Comparable < Object < Kernel < BasicObject

要約

OpenSSL内で利用される多倍長整数クラスです。

通常多倍長整数を利用するには Bignum を用いてください。

特異メソッド

定義 説明
generate_prime(bits, safe=true, add=nil, rem=nil) -> OpenSSL::BN

ランダム(疑似乱数的)な bits ビットの素数を返します。

new(str, base=10) -> OpenSSL::BN

文字列を多倍長整数オブジェクト(OpenSSL::BN)を生成します。

pseudo_rand(bits, fill=0, odd=false) -> OpenSSL::BN

乱数を生成し、返します。

pseudo_rand_range(range) -> OpenSSL::BN

乱数を 0 から range-1 までの間で生成し、返します。

rand(bits, fill=0, odd=false) -> OpenSSL::BN

暗号論的に強い疑似乱数を生成し、返します。

rand_range(range) -> OpenSSL::BN

暗号論的に強い疑似乱数を 0 から range-1 までの間で生成し、返します。

インスタンスメソッド

定義 説明
self % other -> OpenSSL::BN

自身を other で割り算した余りを返します。

self * other -> OpenSSL::BN

自身と other の積を返します。

self ** other -> OpenSSL::BN

自身の other 乗を返します。

self + other -> OpenSSL::BN

自身と other の和を返します。

self - other -> OpenSSL::BN

自身から other を引いた値を返します。

self / other -> [OpenSSL::BN, OpenSSL::BN]

自身を other で割った商と余りを配列で返します。

self << other -> OpenSSL::BN

自身を other ビット左シフトした値を返します。

self <=> other -> -1 | 0 | 1
cmp(other) -> -1 | 0 | 1

自身と other を比較し、otherのほうが小さければ-1、 大きければ+1、等しければ 0 を返します。

self == other -> bool
self === other -> bool
eql?(other) -> bool

自身と other が等しい場合に真を返します。

self >> other -> OpenSSL::BN

自身を other ビット右シフトした値を返します。

bit_set?(n) -> bool

自身の n ビット目が立っているなら真を返します。

clear_bit!(n) -> self

自身の n ビット目を0にします。

coerce(other) -> Array

自身と other が同じクラスになるよう、自身か other を変換し [other, self] という配列にして返します。

copy(other) -> self

other の内容を自身にコピーします。

gcd(other) -> OpenSSL::BN

GCD(最大公約数)を返します。

lshift!(n) -> self

自身を n ビット左シフトします。

mask_bits!(n) -> self

自身を下位 n ビットでマスクします。

mod_add(other, m) -> OpenSSL::BN

(self + other) % m を返します。

mod_exp(other, m) -> OpenSSL::BN

(self ** other) % m を返します。

mod_inverse(m) -> OpenSSL::BN

自身の mod m における逆元を返します。

mod_mul(other, m) -> OpenSSL::BN

(self * other) % m を返します。

mod_sqr(m) -> OpenSSL::BN

(self ** 2) % m を返します。

mod_sub(other, m) -> OpenSSL::BN

(self - other) % m を返します。

num_bits -> Integer

自身を表現するのに使っているビット数を返します。

num_bytes -> Integer

自身を表現するのに使っているバイト数を返します。

odd? -> bool

自身が奇数である場合に真を返します。

one? -> bool

自身が1である場合に真を返します。

prime? -> bool
prime?(checks) -> bool

自身が素数であるなら真を返します。

prime_fasttest?(checks=nil, vtrivdiv=true) -> bool

自身が素数であるなら真を返します。

rshift!(n) -> self

自身を n ビット右シフトします。

set_bit!(n) -> self

自身の n ビット目を1にします。

sqr -> OpenSSL::BN

自身の2乗を計算します。

to_bn -> self

自分自身を返します。

to_i -> Integer
to_int -> Integer

自身を Integer のインスタンスに変換します。

to_s(base=10) -> String

自身を表す文字列を返します。

ucmp(other) -> -1 | 0 | 1

自身と other の絶対値を比較し、other の絶対値のほうが 自身の絶対値より小さければ-1、 大きければ+1、2つの絶対値が等しければ 0 を返します。

zero? -> bool

自身が0である場合に真を返します。

継承したメソッド

! != < <= > >= between? =~ __id__ __send__ _dump class clone dclone display enum_for equal? extend freeze frozen? hash initialize initialize_copy inspect instance_eval instance_exec instance_of? instance_variable_defined? instance_variable_get instance_variable_set instance_variables is_a? marshal_dump marshal_load method method_missing methods must_be must_be_close_to must_be_empty must_be_instance_of must_be_kind_of must_be_nil must_be_same_as must_be_within_epsilon must_equal must_include must_match must_raise must_respond_to must_send must_throw nil? pretty_inspect pretty_print pretty_print_cycle pretty_print_inspect pretty_print_instance_variables private_methods protected_methods public_methods remove_instance_variable respond_to? respond_to_missing? singleton_class singleton_method_added singleton_method_removed singleton_method_undefined singleton_methods taint tainted? tap to_a to_ary to_hash to_io to_proc to_regexp to_str to_yaml to_yaml_properties to_yaml_style trust untaint untrust untrusted? wont_be wont_be_close_to wont_be_empty wont_be_instance_of wont_be_kind_of wont_be_nil wont_be_same_as wont_be_within_epsilon wont_equal wont_include wont_match wont_respond_to