Matrix Encryption Implementation