     }
     printf("%s", msg);
 
-    int *msg_vector = (int *)malloc(strlen(msg)*sizeof(int));
+    float *msg_vector = (float *)malloc(strlen(msg)*sizeof(float));
     // message encoded, results stored in msg_vector
     encode_msg(msg, msg_vector, matrix_dims);
     printf("ENCODED!\n");
-    int msg_vector_list[strlen(msg)/matrix_size][matrix_size];
+
+    float msg_vector_list[msg_size/matrix_size][matrix_size];
     for (i = 0; i < msg_size/matrix_size; i++) {
         printf("\n\nCount: %d %d\n", i, msg_size%matrix_size);
         for (j = 0; j < matrix_size; j++) {
             msg_vector_list[i][j] = msg_vector[i*matrix_size + j];
-            printf("%d\n", msg_vector_list[i][j], "\n");
-        }
-    }
-    
-
-    int nBytes = matrix_size*sizeof(int);
-    int *results = (int *)malloc(nBytes);
+            printf("%f\n", msg_vector_list[i][j], "\n");
+        }
+    }
+    
+    
+    int nBytes = matrix_size*sizeof(float);
+    printf("1\n");
+    float **results = (float **)malloc(msg_size * sizeof(float *));
+    printf("2\n");
+    for (z = 0; z < msg_size/matrix_size; z++) {
+        results[z] = (float *)malloc(matrix_size * sizeof(float));
+    }
+    printf("3\n");
     memset(results, 0, nBytes);
 
     cudaDeviceProp deviceProp;
     cudaGetDeviceProperties(&deviceProp, 0);
     cudaSetDevice(0);
+
+
     float *secretGpu, *msgGpu, *resultGpu;
-
     cudaMalloc((void **)&secretGpu, nBytes);
-    cudaMalloc((void **)&msgGpu, nBytes);
-    cudaMalloc((void **)&resultGpu, nBytes);
-
-    cudaMemcpy(secretGpu, SKey, nBytes, cudaMemcpyHostToDevice);
-    cudaMemcpy(msgGpu, msg_vector_list[0], nBytes, cudaMemcpyHostToDevice);
+
+
+    cudaMalloc((void **)&msgGpu, (msg_size/matrix_size) * sizeof(float *));
+    printf("msg_size/matrix_size: %d \n", msg_size/matrix_size);
+
+
+
+    cudaMalloc((void **)&resultGpu, (msg_size/matrix_size) * sizeof(float *));
+
+
+    cudaMemcpy(secretGpu, *SKey, nBytes, cudaMemcpyHostToDevice);
+    
     dim3 block(matrix_dims, matrix_dims);
     dim3 grid((matrix_dims+block.x-1)/block.x, (matrix_dims+block.y-1)/block.y);
-    mtxEncrypt<<<grid, block>>>(secretGpu, msgGpu, resultGpu, matrix_size);
-
-    cudaMemcpy(results, resultGpu, nBytes, cudaMemcpyDeviceToHost);
-    for (i = 0; i < matrix_size; i++) {
-        printf("%d %d\n", i, results[i]);
-
-    }
-
-
-
-
-
-
-}
-
+
+    for (i = 0; i < msg_size/matrix_size; i++) {
+        cudaMemcpy(msgGpu, msg_vector_list[i], nBytes, cudaMemcpyHostToDevice);
+        mtxEncrypt<<<grid, block>>>(secretGpu, msgGpu, resultGpu, matrix_dims);
+        cudaMemcpy(results[i], resultGpu, nBytes, cudaMemcpyDeviceToHost);
+        printf("\nRESULTS: %d\n", *results);
+    }
+    cudaDeviceSynchronize();
+
+    cudaFree(secretGpu);
+    cudaFree(msgGpu);
+    cudaFree(resultGpu);
+
+    printf("\n\n5\n\n");
+    for (i = 0; i < msg_size/matrix_size; i++) {
+        printf("%d", i);
+        for (j = 0; j < matrix_size; j++) {
+            printf("%d %d\n", i, results[i][j]);
+        }
+    }
+
+    free(results);
+
+    cudaDeviceReset();
+
+    
+
+}
+
+
+
+
+


    // malloc() for 4 (int*) pointers to 4 rows, also malloc'd (int)
    int z;
    int **SKey = (int **) malloc(matrix_dims * sizeof(int *));
    for (z = 0; z < matrix_dims; z++) {
        SKey[z] = (int *)malloc(matrix_dims * sizeof(int));
    }
    int **invSKey = (int **)malloc(matrix_dims * sizeof(int *));
    for (z = 0; z < matrix_dims; z++) {
        invSKey[z] = (int *)malloc(matrix_dims * sizeof(int));
    }

    int msg_size = strlen(msg);

#include <stdlib.h>
#include <cuda_runtime.h>

#define ASCII_CHARS 128

__global__ void mtxEncrypt(float *secretKey, float *msg, float *result, int matrix_dims) {
    int tx = threadIdx.x;
    int ty = threadIdx.y;
    float Pvalue = 0;
  
  //  printf("secretKey: %3.1f, *secretKey: %3.1f, &secretKey: %3.1f, *msg: %3.1f\n", secretKey, *secretKey, &secretKey, *msg);
    for (int k = 0; k < matrix_dims; ++k) {
   //     printf("secretkey[k]: %    
        float secretElement = secretKey[ty * matrix_dims + k];
        float msgElement = msg[k * matrix_dims + tx];
        
  //      printf("\nMultiplying %f by %f: \n", secretElement, msgElement);
        Pvalue  += secretElement * msgElement;
    }
    
//    printf("PValue: %d", (int)Pvalue%ASCII_CHARS);
    result[ty * matrix_dims + tx] = (int)Pvalue%ASCII_CHARS;
}

void secretKey(float **SKey, float **invSKey, int matrix_dims) {
    int k,z;
    //*SKey = malloc((matrix_dims*sizeof(*SKey)) + matrix_dims*matrix_dims*sizeof(int **));
    //*invSKey = malloc(matrix_dims*matrix_dims*sizeof(int *));

    float xSKey[4][4] = {{8, 6, 9, 5},
                {6, 9, 5, 10},
                {5, 8, 4, 9},
                {10, 6, 11, 4}};
    float xinvSKey[4][4] = {{-3, 20, -21, 1},
                    {2, -41, 44, 1},
                    {2, -6, 6, -1},
                    {-1, 28, -30, -1}};
