Sha256: 8250661d996a32aeae0e27c593f2de2afee41e87a443fb7c7a6880002e598d57

Contents?: true

Size: 1.39 KB

Versions: 19

Compression:

Stored size: 1.39 KB

Contents

/**
 * SimpleIVMode
 * 
 * A convenience class that automatically places the IV
 * at the beginning of the encrypted stream, so it doesn't have to
 * be handled explicitely.
 * Copyright (c) 2007 Henri Torgemane
 * 
 * See LICENSE.txt for full license information.
 */
package com.hurlant.crypto.symmetric
{
	import flash.utils.ByteArray;
	import com.hurlant.util.Memory;
	
	public class SimpleIVMode implements IMode, ICipher
	{
		protected var mode:IVMode;
		protected var cipher:ICipher;
		
		public function SimpleIVMode(mode:IVMode) {
			this.mode = mode;
			cipher = mode as ICipher;
		}
		
		public function getBlockSize():uint {
			return mode.getBlockSize();
		}
		
		public function dispose():void {
			mode.dispose();
			mode = null;
			cipher = null;
			Memory.gc();
		}
		
		public function encrypt(src:ByteArray):void {
			cipher.encrypt(src);
			var tmp:ByteArray = new ByteArray;
			tmp.writeBytes(mode.IV);
			tmp.writeBytes(src);
			src.position=0;
			src.writeBytes(tmp);
		}
		
		public function decrypt(src:ByteArray):void {
			var tmp:ByteArray = new ByteArray;
			tmp.writeBytes(src, 0, getBlockSize());
			mode.IV = tmp;
			tmp = new ByteArray;
			tmp.writeBytes(src, getBlockSize());
			cipher.decrypt(tmp);
			src.length=0;
			src.writeBytes(tmp);
		}
		public function toString():String {
			return "simple-"+cipher.toString();
		}
	}
}

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/symmetric/SimpleIVMode.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/symmetric/SimpleIVMode.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/symmetric/SimpleIVMode.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/symmetric/SimpleIVMode.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/symmetric/SimpleIVMode.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/symmetric/SimpleIVMode.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/symmetric/SimpleIVMode.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/symmetric/SimpleIVMode.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/symmetric/SimpleIVMode.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/symmetric/SimpleIVMode.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/symmetric/SimpleIVMode.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/symmetric/SimpleIVMode.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/symmetric/SimpleIVMode.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/symmetric/SimpleIVMode.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/symmetric/SimpleIVMode.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/symmetric/SimpleIVMode.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/symmetric/SimpleIVMode.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/symmetric/SimpleIVMode.as
rocket-js-0.0.2 src/vendor/web-socket-js/flash-src/com/hurlant/crypto/symmetric/SimpleIVMode.as