Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sha256 produces wrong output for á #10

Closed
GoogleCodeExporter opened this issue Mar 27, 2016 · 2 comments
Closed

sha256 produces wrong output for á #10

GoogleCodeExporter opened this issue Mar 27, 2016 · 2 comments

Comments

@GoogleCodeExporter
Copy link

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
Copy link
Author

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
Copy link
Author

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

  • Changed state: Invalid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant