FileDocCategorySizeDatePackage
TransportHelperFilterStreamXOR.javaAPI DocAzureus 3.0.3.42305Mon Mar 05 14:57:18 GMT 2007com.aelitis.azureus.core.networkmanager.impl

TransportHelperFilterStreamXOR

public class TransportHelperFilterStreamXOR extends TransportHelperFilterStream

Fields Summary
private byte[]
mask
private int
read_position
private int
write_position
Constructors Summary
protected TransportHelperFilterStreamXOR(TransportHelper _transport, byte[] _mask)

		super( _transport );
		
		mask		= _mask;
	
Methods Summary
protected voidcryptoIn(java.nio.ByteBuffer source_buffer, java.nio.ByteBuffer target_buffer)

		
		int	rem = source_buffer.remaining();
		
		for (int i=0;i<rem;i++){
			
			byte	b = source_buffer.get();
			
			b = (byte)( b ^ mask[ read_position++ ]);
			
			target_buffer.put( b );
			
			if ( read_position == mask.length  ){
				
				read_position	= 0;
			}
		}	
	
protected voidcryptoOut(java.nio.ByteBuffer source_buffer, java.nio.ByteBuffer target_buffer)

		
		int	rem = source_buffer.remaining();
		
		for (int i=0;i<rem;i++){
			
			byte	b = source_buffer.get();
			
			b = (byte)( b ^ mask[ write_position++ ]);
			
			target_buffer.put( b );
			
			if ( write_position == mask.length  ){
				
				write_position	= 0;
			}
		}
	
public java.lang.StringgetName()

		return( "XOR-" + mask.length*8 + getHelper().getName());
	
public booleanisEncrypted()

		return( true );