Construct a new OpenSSL
BIGNUM object.
The string must contain a valid cipher name like “AES-256-CBC”.
A list of cipher names is available by calling OpenSSL::Cipher.ciphers
.
Creates an instance of OpenSSL’s configuration class.
This can be used in contexts like OpenSSL::X509::ExtensionFactory.config=
If the optional filename parameter is provided, then it is read in and parsed via parse_config.
This can raise IO
exceptions based on the access, or availability of the file. A ConfigError
exception may be raised depending on the validity of the data being configured.
Creates a Digest
instance based on string, which is either the ln (long name) or sn (short name) of a supported digest algorithm.
If data (a String
) is given, it is used as the initial input to the Digest
instance, i.e.
digest = OpenSSL::Digest.new('sha256', 'digestdata')
is equivalent to
digest = OpenSSL::Digest.new('sha256') digest.update('digestdata')
Returns an instance of OpenSSL::HMAC
set with the key and digest algorithm to be used. The instance represents the initial state of the message authentication code before any data has been processed. To process data with it, use the instance method update
with your data as an argument.
key = 'key' digest = OpenSSL::Digest.new('sha1') instance = OpenSSL::HMAC.new(key, digest) #=> f42bb0eeb018ebbd4597ae7213711ec60760843f instance.class #=> OpenSSL::HMAC
Two instances can be securely compared with ==
in constant time:
other_instance = OpenSSL::HMAC.new('key', OpenSSL::Digest.new('sha1')) #=> f42bb0eeb018ebbd4597ae7213711ec60760843f instance == other_instance #=> true
Many methods in this class aren’t documented.
Creates a new Psych::Parser
instance with handler
. YAML
events will be called on handler
. See Psych::Parser
for more details.
Create a new scanner
Create a new TreeBuilder
instance
Create a new Psych::Emitter
that writes to io
.
Creates a new Ripper::Filter
instance, passes parameters src
, filename
, and lineno
to Ripper::Lexer.new
The lexer is for internal use only.
family should be an integer, a string or a symbol.
Socket::AF_INET, “AF_INET”, “INET”, :AF_INET, :INET
Socket::AF_UNIX, “AF_UNIX”, “UNIX”, :AF_UNIX, :UNIX
etc.
cmsg_level should be an integer, a string or a symbol.
Socket::SOL_SOCKET, “SOL_SOCKET”, “SOCKET”, :SOL_SOCKET and :SOCKET
Socket::IPPROTO_IP, “IP” and :IP
Socket::IPPROTO_IPV6, “IPV6” and :IPV6
Socket::IPPROTO_TCP, “TCP” and :TCP
etc.
cmsg_type should be an integer, a string or a symbol. If a string/symbol is specified, it is interpreted depend on cmsg_level.
Socket::SCM_RIGHTS, “SCM_RIGHTS”, “RIGHTS”, :SCM_RIGHTS, :RIGHTS for SOL_SOCKET
Socket::IP_RECVTTL, “RECVTTL” and :RECVTTL for IPPROTO_IP
Socket::IPV6_PKTINFO, “PKTINFO” and :PKTINFO for IPPROTO_IPV6
etc.
cmsg_data should be a string.
p Socket::AncillaryData.new(:INET, :TCP, :NODELAY, "") #=> #<Socket::AncillaryData: INET TCP NODELAY ""> p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "") #=> #<Socket::AncillaryData: INET6 IPV6 PKTINFO "">
remote_address
is an Addrinfo
object.
local_address
is an Addrinfo
object.
reply_proc
is a Proc
used to send reply back to the source.
Returns a new Socket::Option
object.
sockopt = Socket::Option.new(:INET, :SOCKET, :KEEPALIVE, [1].pack("i")) p sockopt #=> #<Socket::Option: INET SOCKET KEEPALIVE 1>
Fills in variables for Logger
compatibility. If this is the first instance of Syslog::Logger
, program_name
may be set to change the logged program name. The facility
may be set to specify the facility level which will be used.
Due to the way syslog works, only one program name may be chosen.
initialize
Creates a new deflate stream for compression. If a given argument is nil, the default value of that argument is used.
The level
sets the compression level for the deflate stream between 0 (no compression) and 9 (best compression). The following constants have been defined to make code more readable:
Zlib::DEFAULT_COMPRESSION
Zlib::NO_COMPRESSION
Zlib::BEST_SPEED
Zlib::BEST_COMPRESSION
See www.zlib.net/manual.html#Constants for further information.
The window_bits
sets the size of the history buffer and should be between 8 and 15. Larger values of this parameter result in better compression at the expense of memory usage.
The mem_level
specifies how much memory should be allocated for the internal compression state. 1 uses minimum memory but is slow and reduces compression ratio while 9 uses maximum memory for optimal speed. The default value is 8. Two constants are defined:
Zlib::DEF_MEM_LEVEL
Zlib::MAX_MEM_LEVEL
The strategy
sets the deflate compression strategy. The following strategies are available:
For normal data
For data produced by a filter or predictor
Prevents dynamic Huffman codes
Prevents string matching
Designed for better compression of PNG image data
See the constants for further description.
open "compressed.file", "w+" do |io| io << Zlib::Deflate.new.deflate(File.read("big.file")) end
open "compressed.file", "w+" do |compressed_io| deflate = Zlib::Deflate.new(Zlib::BEST_COMPRESSION, Zlib::MAX_WBITS, Zlib::MAX_MEM_LEVEL, Zlib::HUFFMAN_ONLY) begin open "big.file" do |big_io| until big_io.eof? do compressed_io << zd.deflate(big_io.read(16384)) end end ensure deflate.close end end
While this example will work, for best optimization review the flags for your specific time, memory usage and output space requirements.
Creates a new inflate stream for decompression. window_bits
sets the size of the history buffer and can have the following values:
Have inflate use the window size from the zlib header of the compressed stream.
Overrides the window size of the inflate header in the compressed stream. The window size must be greater than or equal to the window size of the compressed stream.
Add 32 to window_bits to enable zlib and gzip decoding with automatic header detection, or add 16 to decode only the gzip format (a Zlib::DataError
will be raised for a non-gzip stream).
Enables raw deflate mode which will not generate a check value, and will not look for any check values for comparison at the end of the stream.
This is for use with other formats that use the deflate compressed data format such as zip which provide their own check values.
open "compressed.file" do |compressed_io| zi = Zlib::Inflate.new(Zlib::MAX_WBITS + 32) begin open "uncompressed.file", "w+" do |uncompressed_io| uncompressed_io << zi.inflate(compressed_io.read) end ensure zi.close end end
Creates a GzipWriter
object associated with io
. level
and strategy
should be the same as the arguments of Zlib::Deflate.new
. The GzipWriter
object writes gzipped data to io
. io
must respond to the write
method that behaves the same as IO#write
.
The options
hash may be used to set the encoding of the data. :external_encoding
, :internal_encoding
and :encoding
may be set as in IO::new
.
Creates a GzipReader
object associated with io
. The GzipReader
object reads gzipped data from io
, and parses/decompresses it. The io
must have a read
method that behaves same as the IO#read
.
The options
hash may be used to set the encoding of the data. :external_encoding
, :internal_encoding
and :encoding
may be set as in IO::new
.
If the gzip file header is incorrect, raises an Zlib::GzipFile::Error
exception.