2bwithu / crypto-js

Automatically exported from code.google.com/p/crypto-js
0 stars 0 forks source link

sha256 produces wrong output for á #10

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. run Crypto.SHA256("á") in firebug

What is the expected output?
fb9778719d93551b1c88df5f1ab229f83ea30af112fc51017c9f0a383dcf6cb3

What do you see instead?
eb3e85d7fbf56104c8021681e68d771b9b9205b93e9219c8f81f60af703de381

What version of the product are you using?
2.0.0

On what operating system?
Mac/Chrome 7

Original issue reported on code.google.com by key...@gmail.com on 17 Nov 2010 at 3:25

GoogleCodeExporter commented 9 years ago
When you write non-ASCII characters directly into your page source, you need to 
make sure you use a meta tag to set the charset. To see the difference it 
causes, consider these two sources below.

/* No META charset */
<script type="text/javascript" 
src="http://crypto-js.googlecode.com/files/2.0.0-crypto-sha256.js"></script>
<script type="text/javascript">
var m = "á";
alert(m.length); // alerts 2
alert(Crypto.SHA256(m)); // alerts 
eb3e85d7fbf56104c8021681e68d771b9b9205b93e9219c8f81f60af703de381
</script>

/* Has META charset */
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" 
src="http://crypto-js.googlecode.com/files/2.0.0-crypto-sha256.js"></script>
<script type="text/javascript">
var m = "á";
alert(m.length); // alerts 1
alert(Crypto.SHA256(m)); // alerts 
fb9778719d93551b1c88df5f1ab229f83ea30af112fc51017c9f0a383dcf6cb3
</script>

Original comment by Jeff.Mott.OR on 17 Nov 2010 at 5:21

GoogleCodeExporter commented 9 years ago

Original comment by Jeff.Mott.OR on 18 Nov 2010 at 5:52