Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

OpenSSL::BN#to_s

bn.to_s(base = 10) → string

Returns the string representation of the bignum.

BN.new can parse the encoded string to convert back into an OpenSSL::BN.

base

The format. Must be one of the following:

  • 0 - MPI format. See the man page BN_bn2mpi(3) for details.

  • 2 - Variable-length and big-endian binary encoding. The sign of the bignum is ignored.

  • 10 - Decimal number representation, with a leading ‘-’ for a negative bignum.

  • 16 - Hexadeciaml number representation, with a leading ‘-’ for a negative bignum.

See also #to_int #ucmp #to_i #zero? also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0