We are developing a Java based application and use Hibernate for DAO. I have an XML data store as Clob in the database. With Hibernate Clob object and parse it into a String. Then I HASH(SHA-256) it.
The Clob object has 2 method.
getAsciiStream()
returnsInputSteam
getCharacterStream()
returnsReader
The parser parses the InputStream
or Reader
into a exactly same String. However the Hash generated from each of them are different. Why?
Context: We currently are using getAsciiStream()
and it limits many special characters. So we have to change it getCharacterStream()
. However, our application (it does hash comparison for business reasons) and customers will be affected with the change.
Example XML:
<application>
<header>
<subtitle>WHAT EVER</subtitle>
<page_header>WHAT EVER</page_header>
</header>
<form>
<application_form_name>WHAT EVER</application_form_name>
<section>
<section_name>WHAT EVER</section_name>
<question>
<question_text>How is this applicant to something?</question_text>
<answer>WHAT EVER</answer>
</question>
<question>
<question_text>What is something?</question_text>
<answer>WHAT EVER</answer>
</question>
<question>
<question_text>Type of Customer</question_text>
<answer>Organization</answer>
</question>
<question>
<question_text>Full legal name of the applicant:</question_text>
<answer/>
</question>
<question>
<question_text>Legal Name</question_text>
<answer>WHAT EVER</answer>
</question>
<question>
<question_text>WHAT EVER</question_text>
<answer/>
</question>
<question>
<question_text>WHAT EVER</question_text>
<answer/>
</question>
<question>
<question_text>WHAT EVER</question_text>
<answer/>
</question>
<question>
<question_text>WHAT EVER</question_text>
<answer/>
</question>
</section>
</form>
</application>