SHA512JS (SHA512 for JavaScript)

version1.2.0
last update: Jun 5 2016

PLATFORM
Web Brwoser (HTML: JavaScript)
WSH (Windows Script Host: JScript)
Node.js

Description:
Calculate SHA512

Develop Environment:
Windows7 Starter SP1
Test Browswer (success running)

Source Files

Download ZIP File
Download TAR Ball
View On GitHub



Demo Page



Example1: Web Browser (html)
<script type="text/javascript" src="sha512.js"></script>
<script type="text/javascript">
	
	var data = 'abcd'; // String (use lower 8bit of character code)
	
	var cnt = SHA512JS.create();
	
	SHA512JS.init(cnt);
	
	SHA512JS.updateByByteString(cnt, data, 0, data.length);
	
	SHA512JS.finish(cnt);
	
	var hash = SHA512JS.toHexString(cnt); // d8022f2060ad6efd297ab73dcc5355c9b214054b0d1776a136a669d26a7d3b14f73aa0d0ebff19ee333368f0164b6419a96da49e3e481753e7e96b716bdccb6f
	
</script>

Example2: WSH (Windows Script Host)
<?xml version="1.0"?>
<job id="sampleSHA512">
	<script language="JScript" src="sha512.js" />
	<script language="JScript">
		<![CDATA[
			function testJS() {
				var cnt = SHA512JS.create();
				SHA512JS.init(cnt);
				SHA512JS.updateByByteString(cnt, 'abc', 0, 3);
				SHA512JS.finish(cnt);
				var hash = SHA512JS.toHexString(cnt);
				WScript.Echo('JScript:\n' + hash);
			}
			testJS();
		]]>
	</script>
	<script language="VBScript">
		<![CDATA[
			Sub testVBS()
				Dim cnt, hash
				Set cnt = SHA512JS.create()
				SHA512JS.init cnt
				SHA512JS.updateByByteString cnt, "abc", 0, 3
				SHA512JS.finish cnt
				hash = SHA512JS.toHexString(cnt)
				WScript.Echo "VBScript:" & vbNewLine & hash
			End Sub
			Call testVBS
		]]>
	</script>
</job>

LICENSE

The MIT License (MIT)

Copyright (c) 2016 Leonardone @ NEETSDKASU

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.