Generates a new key (pair).
If a String
is given as the first argument, it generates a new random key for the algorithm specified by the name just as ::generate_parameters
does. If an OpenSSL::PKey::PKey
is given instead, it generates a new random key for the same algorithm as the key, using the parameters the key contains.
See ::generate_parameters
for the details of options and the given block.
pkey_params = OpenSSL::PKey.generate_parameters("DSA", "dsa_paramgen_bits" => 2048) pkey_params.priv_key #=> nil pkey = OpenSSL::PKey.generate_key(pkey_params) pkey.priv_key #=> #<OpenSSL::BN 6277...
PKCS #5 PBKDF2 (Password-Based Key Derivation Function 2) in combination with HMAC
. Takes pass, salt and iterations, and then derives a key of length bytes.
For more information about PBKDF2, see RFC 2898 Section 5.2 (tools.ietf.org/html/rfc2898#section-5.2).
The password.
The salt. Salts prevent attacks based on dictionaries of common passwords and attacks based on rainbow tables. It is a public value that can be safely stored along with the password (e.g. if the derived value is used for password storage).
The iteration count. This provides the ability to tune the algorithm. It is better to use the highest count possible for the maximum resistance to brute-force attacks.
The desired length of the derived key in octets.
The hash algorithm used with HMAC
for the PRF. May be a String
representing the algorithm name, or an instance of OpenSSL::Digest
.
Generates a mask bit for a priority level. See mask=
Returns an Array
of individual raw profile data Hashes ordered from earliest to latest by :GC_INVOKE_TIME
.
For example:
[ { :GC_TIME=>1.3000000000000858e-05, :GC_INVOKE_TIME=>0.010634999999999999, :HEAP_USE_SIZE=>289640, :HEAP_TOTAL_SIZE=>588960, :HEAP_TOTAL_OBJECTS=>14724, :GC_IS_MARKED=>false }, # ... ]
The keys mean:
:GC_TIME
:GC_INVOKE_TIME
Time
elapsed in seconds from startup to when the GC
was invoked
:HEAP_USE_SIZE
Total bytes of heap used
:HEAP_TOTAL_SIZE
Total size of heap in bytes
:HEAP_TOTAL_OBJECTS
Total number of objects
:GC_IS_MARKED
Returns true
if the GC
is in mark phase
If ruby was built with GC_PROFILE_MORE_DETAIL
, you will also have access to the following hash keys:
:GC_MARK_TIME
:GC_SWEEP_TIME
:ALLOCATE_INCREASE
:ALLOCATE_LIMIT
:HEAP_USE_PAGES
:HEAP_LIVE_OBJECTS
:HEAP_FREE_OBJECTS
:HAVE_FINALIZE
Generate a sequence of checkbox elements, as a String
.
The checkboxes will all have the same name
attribute. Each checkbox is followed by a label. There will be one checkbox for each value. Each value can be specified as a String
, which will be used both as the value of the VALUE attribute and as the label for that checkbox. A single-element array has the same effect.
Each value can also be specified as a three-element array. The first element is the VALUE attribute; the second is the label; and the third is a boolean specifying whether this checkbox is CHECKED.
Each value can also be specified as a two-element array, by omitting either the value element (defaults to the same as the label), or the boolean checked element (defaults to false).
checkbox_group("name", "foo", "bar", "baz") # <INPUT TYPE="checkbox" NAME="name" VALUE="foo">foo # <INPUT TYPE="checkbox" NAME="name" VALUE="bar">bar # <INPUT TYPE="checkbox" NAME="name" VALUE="baz">baz checkbox_group("name", ["foo"], ["bar", true], "baz") # <INPUT TYPE="checkbox" NAME="name" VALUE="foo">foo # <INPUT TYPE="checkbox" CHECKED NAME="name" VALUE="bar">bar # <INPUT TYPE="checkbox" NAME="name" VALUE="baz">baz checkbox_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz") # <INPUT TYPE="checkbox" NAME="name" VALUE="1">Foo # <INPUT TYPE="checkbox" CHECKED NAME="name" VALUE="2">Bar # <INPUT TYPE="checkbox" NAME="name" VALUE="Baz">Baz checkbox_group("NAME" => "name", "VALUES" => ["foo", "bar", "baz"]) checkbox_group("NAME" => "name", "VALUES" => [["foo"], ["bar", true], "baz"]) checkbox_group("NAME" => "name", "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"])
Generate an Image Button Input element as a string.
src
is the URL of the image to use for the button. name
is the input name. alt
is the alternative text for the image.
Alternatively, the attributes can be specified as a hash.
image_button("url") # <INPUT TYPE="image" SRC="url"> image_button("url", "name", "string") # <INPUT TYPE="image" SRC="url" NAME="name" ALT="string"> image_button("SRC" => "url", "ALT" => "string") # <INPUT TYPE="image" SRC="url" ALT="string">
Calls the block with each key/value pair:
res = Net::HTTP.get_response(hostname, '/todos/1') res.each_header do |key, value| p [key, value] if key.start_with?('c') end
Output:
["content-type", "application/json; charset=utf-8"] ["connection", "keep-alive"] ["cache-control", "max-age=43200"] ["cf-cache-status", "HIT"] ["cf-ray", "771d17e9bc542cf5-ORD"]
Returns an enumerator if no block is given.
Net::HTTPHeader#each
is an alias for Net::HTTPHeader#each_header
.
Calls the block with each field key:
res = Net::HTTP.get_response(hostname, '/todos/1') res.each_key do |key| p key if key.start_with?('c') end
Output:
"content-type" "connection" "cache-control" "cf-cache-status" "cf-ray"
Returns an enumerator if no block is given.
Net::HTTPHeader#each_name
is an alias for Net::HTTPHeader#each_key
.
Calls the block with each string field value:
res = Net::HTTP.get_response(hostname, '/todos/1') res.each_value do |value| p value if value.start_with?('c') end
Output:
"chunked" "cf-q-config;dur=6.0000002122251e-06" "cloudflare"
Returns an enumerator if no block is given.
Like each_header
, but the keys are returned in capitalized form.
Net::HTTPHeader#canonical_each
is an alias for Net::HTTPHeader#each_capitalized
.
Returns the leading (‘type’) part of the media type from the value of field 'Content-Type'
, or nil
if no such field exists; see Content-Type response header:
res = Net::HTTP.get_response(hostname, '/todos/1') res['content-type'] # => "application/json; charset=utf-8" res.main_type # => "application"
Return a Hash
for RJIT statistics. --rjit-stats makes more information available.
Creates an unsigned certificate for subject
and key
. The lifetime of the key is from the current time to age
which defaults to one year.
The extensions
restrict the key to the indicated uses.
Creates a new digest instance using the specified algorithm
. The default is SHA256.
Creates a new key pair of the specified algorithm
. RSA, DSA, and EC are supported.
Enumerates the trusted certificates via Gem::Security::TrustDir
.
Simple deprecation method that deprecates name
by wrapping it up in a dummy method. It warns on each call to the dummy method telling the user of repl
(unless repl
is :none) and the Rubygems version that it is planned to go away.
Simple deprecation method that deprecates name
by wrapping it up in a dummy method. It warns on each call to the dummy method telling the user of repl
(unless repl
is :none) and the Rubygems version that it is planned to go away.