Exemplo n.º 1
0
int main(int argc, const char * argv[])
{
    //first, we create the linked list header
    node *root = malloc(sizeof(node));
    node *end = malloc(sizeof(node));
    
    root->next = end;
    end->prev = root;
    end->next = NULL;
    node *current_node = root;
    
    int index;
    int list_size = 100;
    
    //then make linked list of 350
    //this will be our usable coefficient buffer
    for (index = 0; index<list_size; index++){
        int random_number = arc4random() % 150;
        random_number =  (random_number%2)? random_number*-1: random_number;
        
        node *new_node = malloc(sizeof(node));
        new_node->coeff_struct.coefficient = random_number;
        
        add_to_linked_list(new_node, current_node);
        current_node = current_node->next;
    }
    
    printf("\n");
    printf("loop coefficients are: ");
    //print_linked_list(root);
    printf("\n");
    
    char *message = "Hello";/* that whirl me I know not whither\nYour schemes, politics, fail, lines give way, substances mock and elude me,\nOnly the theme I sing, the great and strong-possess'd soul, eludes not,\nOne's-self must never give way--that is the final substance--that\nout of all is sure,\nOut of politics, triumphs, battles, life, what at last finally remains?\nWhen shows break up what but One's-Self is sure?";*/
    
    embedMessageIntoCoefficients(message, root, list_size);
    
    printf("\n\nour stego coefficients: \n");
    print_linked_list(root);
    
    printf("\n");
    int message_size = (int)strlen(message)*8; //getting size of message in bits
    char *extractedMessage = malloc(sizeof(char) *message_size);
    extractMessageFromCoefficients(root, list_size, message_size, extractedMessage);
    
    return 0;
}
Exemplo n.º 2
0
static void embed(JBLOCKARRAY *coef_buffers, const char *embedMessage, node *root, size_t root_len)
{
    {
        //going along random walk as produced by the CPRNG, embed/extract message into coefficients using binary hamming matrix code
        embedMessageIntoCoefficients(embedMessage, root, root_len);
        
        //then go back and update JPEG's coefficients with the changed coefficients accordingly, using the indices data stored in the coefficient struct
        printf("changing coefficients\n");
        node *current_node = root->next;
        while (current_node != NULL) {
            JCOEF coefficient = current_node->coeff_struct.coefficient;
            coef_buffers[0][current_node->coeff_struct.row_index][current_node->coeff_struct.column_index][current_node->coeff_struct.block_index] = coefficient;
            current_node = current_node->next;
        }

        printf("done embedding\n");
    }
}