Issue #6799 has been updated by Eregon (Benoit Daloze). @Aaron: Maybe String#unpack should be fixed instead to return an ASCII string for the 'H', 'h', 'B' and 'b' directives? It makes sense to me since these will always contain 0-9a-f (0-1 for 'B','b') chars. This is already done for the 'm', 'M' and 'u' directives in Array#pack. What do you think? P.S.: Does anyone know the rationale behind which method to use for 'u','m','M' and 'H','h','B','b' ? To have a base64 representation you need [s].pack('m') (and so #pack is used for 'u','m','M' to obtain the specified format), but for 'H','h','B','b' you need s.unpack(directive). I think the latter makes more sense when compared to other types such as 'l', in which #unpack is used to obtain the desired format. ---------------------------------------- Bug #6799: Digest::*.hexdigest returns an ASCII-8BIT String https://bugs.ruby-lang.org/issues/6799#change-29304 Author: Eregon (Benoit Daloze) Status: Closed Priority: Normal Assignee: Eregon (Benoit Daloze) Category: ext Target version: 2.0.0 ruby -v: ruby 2.0.0dev (2012-07-15 trunk 36395) [x86_64-darwin10.8.0] $ ruby -rdigest/sha1 -e 'p Digest::SHA1.hexdigest("a").encoding' #<Encoding:ASCII-8BIT> I'm happy to provide a patch. -- http://bugs.ruby-lang.org/