public void Run( SaveBlock buffer, int offset, int length ) { for( int i = offset; i < offset + length; i += 2 ) { //test this little endian conversion var bitmask = Next(); buffer[i] = (byte) ( buffer[i] ^ ( ( ( bitmask & 0xff00 ) >> 8 ) ) ); buffer[i + 1] = (byte) ( buffer[i + 1] ^ ( bitmask & 0xff ) ); } }
public static void BlocksForEncryption( SaveBlock _buffer, uint Personality ) { ShuffleBlocks( _buffer, Personality, toencrypt ); }
static void ShuffleBlocks( SaveBlock _buffer, uint Personality, int[] indexes ) { var blocks = new byte[4][]; for( int i = 0; i < 4; i++ ) { blocks[i] = new byte[32]; for( int j = 0; j < 32; j++ ) { blocks[i][j] = _buffer[i * 32 + j]; } } for( int i = 0; i < 4; i++ ) { var toindex = ExtractShuffleIndexFromArray( i, Personality, indexes ); for( int j = 0; j < 32; j++ ) { _buffer[toindex * 32 + j] = blocks[i][j]; } } }
public NdsPkm( SaveBlock buffer, bool fromPkm ) { _buffer = buffer; EncryptionState = fromPkm ? PkmState.Decrypted : PkmState.Encrypted; }