Sha256: 533ee366ad5fe0a1d6b1d262844d9e107f797e57d6b7f5081ca4bb6e4fe7ad45

Contents?: true

Size: 1.42 KB

Versions: 19

Compression:

Stored size: 1.42 KB

Contents

/**
 * 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");
			h.endTestCase();
		}
		
		/**
		 * Sad test vectors pilfered from
		 * http://en.wikipedia.org/wiki/RC4
		 */
		public function testLameVectors():void {
			var keys:Array = [
			Hex.fromString("Key"),
			Hex.fromString("Wiki"),
			Hex.fromString("Secret")];
			var pts:Array = [
			Hex.fromString("Plaintext"),
			Hex.fromString("pedia"),
			Hex.fromString("Attack at dawn")];
			var cts:Array = [
			"BBF316E8D940AF0AD3",
			"1021BF0420",
			"45A01F645FC35B383552544B9BF5"];
			
			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);
				rc4.encrypt(pt);
				var out:String = Hex.fromArray(pt).toUpperCase();
				assert("comparing "+cts[i]+" to "+out, cts[i]==out);
				// now go back to plaintext
				rc4.init(key);
				rc4.decrypt(pt);
				out = Hex.fromArray(pt);
				assert("comparing "+pts[i]+" to "+out, pts[i]==out);
			}
		}
		
	}
}

Version data entries

19 entries across 19 versions & 4 rubygems

Version Path
hooch-0.4.2 jasmine/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ARC4Test.as
hooch-0.4.1 jasmine/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ARC4Test.as
hooch-0.4.0 jasmine/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ARC4Test.as
hooch-0.3.0 jasmine/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ARC4Test.as
hooch-0.2.1 jasmine/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ARC4Test.as
hooch-0.2.0 jasmine/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ARC4Test.as
hooch-0.1.0 jasmine/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ARC4Test.as
hooch-0.0.8 jasmine/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ARC4Test.as
hooch-0.0.7 jasmine/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ARC4Test.as
hooch-0.0.6 jasmine/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ARC4Test.as
entangled-0.0.16 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ARC4Test.as
entangled-0.0.15 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ARC4Test.as
entangled-0.0.14 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ARC4Test.as
entangled-0.0.13 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ARC4Test.as
entangled-0.0.12 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ARC4Test.as
entangled-0.0.11 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ARC4Test.as
entangled-0.0.10 spec/dummy/public/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ARC4Test.as
coffeecake-0.0.1 node_modules/jasmine-runner/node_modules/socket.io/support/socket.io-client/lib/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ARC4Test.as
rocket-js-0.0.2 src/vendor/web-socket-js/flash-src/com/hurlant/crypto/tests/ARC4Test.as