Issue #5156 has been reported by Martin Ceronio.

----------------------------------------
Bug #5156: Problem with creating a SHA2 digest hash when string has character sequence "#$"
http://redmine.ruby-lang.org/issues/5156

Author: Martin Ceronio
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
ruby -v: ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-linux], ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-mingw32] 


When calculating a SHA2 hash in Ruby using Digest::SHA2, it gives weird results.

Consider the following string: "968901L#$q675PwX" which has a SHA2 hash of 6659bd73f7295ee5ddc35dc03e46274e30c2488bacd4f7d4926e5649202918b9 (confirmed with http://www.xorbin.com/tools/sha256-hash-calculator and ABAP language as well).

Using Digest::SHA2 in Ruby, the hash is 6b9139de7a8d0e7436e98a4e39317e54642f2e4185c31c9395ce7a12cfd56627.

Where things seem to fall apart is from the hash and dollar sign ("#$") onwards. If you try hash a string ending in "#$" with Digest::SHA2, it gives an exception in Ruby ("unterminated string meets end of file").

Tested under Windows and Linux with Ruby 1.8.7. Specifically:
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-linux]
ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-mingw32]



-- 
http://redmine.ruby-lang.org