MyIOTest / myiotestb / static / web-socket-js / flash-src / third-party / com / hurlant / crypto / tests /

The default branch has multiple heads

 * ARC4Test
 * A test class for ARC4
 * Copyright (c) 2007 Henri Torgemane
 * See LICENSE.txt for full license information.
package com.hurlant.crypto.tests
	import com.hurlant.util.Hex;
	import flash.utils.ByteArray;
	import com.hurlant.crypto.prng.ARC4;
	public class ARC4Test extends TestCase
		public function ARC4Test(h:ITestHarness)
			super(h, "ARC4 Test");
			runTest(testLameVectors,"ARC4 Test Vectors");
		 * Sad test vectors pilfered from
		public function testLameVectors():void {
			var keys:Array = [
			var pts:Array = [
			Hex.fromString("Attack at dawn")];
			var cts:Array = [
			for (var i:uint=0;i<keys.length;i++) {
				var key:ByteArray = Hex.toArray(keys[i]);
				var pt:ByteArray = Hex.toArray(pts[i]);
				var rc4:ARC4 = new ARC4(key);
				var out:String = Hex.fromArray(pt).toUpperCase();
				assert("comparing "+cts[i]+" to "+out, cts[i]==out);
				// now go back to plaintext
				out = Hex.fromArray(pt);
				assert("comparing "+pts[i]+" to "+out, pts[i]==out);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.