ruby-changes:70195
From: Nobuyoshi <ko1@a...>
Date: Tue, 14 Dec 2021 12:00:32 +0900 (JST)
Subject: [ruby-changes:70195] 900e0c8c39 (master): [ruby/securerandom] Use String#unpack1
https://git.ruby-lang.org/ruby.git/commit/?id=900e0c8c39 From 900e0c8c39fe3df72d7ce451e01c1add7b6f1647 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Tue, 14 Dec 2021 00:55:02 +0900 Subject: [ruby/securerandom] Use String#unpack1 https://github.com/ruby/securerandom/commit/5460a18c35 --- lib/random/formatter.rb | 2 +- test/ruby/test_random_formatter.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/random/formatter.rb b/lib/random/formatter.rb index d7e7b1f77a1..744853a4b71 100644 --- a/lib/random/formatter.rb +++ b/lib/random/formatter.rb @@ -71,7 +71,7 @@ module Random::Formatter https://github.com/ruby/ruby/blob/trunk/lib/random/formatter.rb#L71 # prng.hex #=> "eb693ec8252cd630102fd0d0fb7c3485" # prng.hex #=> "91dc3bfb4de5b11d029d376634589b61" def hex(n=nil) - random_bytes(n).unpack("H*")[0] + random_bytes(n).unpack1("H*") end # Random::Formatter#base64 generates a random base64 string. diff --git a/test/ruby/test_random_formatter.rb b/test/ruby/test_random_formatter.rb index df3320b41c8..a5072099e1b 100644 --- a/test/ruby/test_random_formatter.rb +++ b/test/ruby/test_random_formatter.rb @@ -27,9 +27,9 @@ module Random::Formatter https://github.com/ruby/ruby/blob/trunk/test/ruby/test_random_formatter.rb#L27 end def test_base64 - assert_equal(16, @it.base64.unpack('m*')[0].size) + assert_equal(16, @it.base64.unpack1('m*').size) 17.times do |idx| - assert_equal(idx, @it.base64(idx).unpack('m*')[0].size) + assert_equal(idx, @it.base64(idx).unpack1('m*').size) end end -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/