Ejemplo n.º 1
0
main(int argc,char *argv[])
{
    long int i,j,k,l,n1,n2,nl;
    if(argc==3)
    {
        clrscr();

        fp1=fopen(argv[1],"rb");
        fp2=fopen(file3,"wb");

        fseek(fp1,0,2);
        l=ftell(fp1);
        n1=l/32;
        n2=l%32;
        fseek(fp1,0,0);
        nl=0;
        for(i=0; i<16; i++)
            for(j=0; j<16; j++)
                mat[i][j]= nl++;
        clrscr();
        keygen();
        /* To envoke randomizetion() function secure-times */
        for(i=1; i<=secure; i++)
            randomization();
        for(i=1; i<=n1; i++)
        {
            fread(&data1,sizeof(data1),1,fp1);
            bit_stream(data1.ch);
            encrypt_bit();
        }

        if (n2!=0)
        {
            for(i=0; i<n2; i++)
            {
                fscanf(fp1,"%c",&data2[i]);
                data2[i]=rshift_residual(data2[i],5);
                /*data2[i]=data2[i]^255;*/
                fprintf(fp2,"%c",data2[i]);
            }
        }

        fcloseall();
        /*msa_encryption(file3,file2);*/
        msa_encryption(file3,argv[2]);

        printf("\nData encryption is over.\n\n");
        getch();
    }
    else
        printf("\n***Invalid command line arguments***\n");
}
Ejemplo n.º 2
0
BMallocIO *DragonView::_TranslateBitmap( BMessage *msg, char **type_out )
{
	// We'll need to access the Translation Kit's BTranslatorRoster...

	BTranslatorRoster *roster = BTranslatorRoster::Default();
	
	// We'll start by looking through be:types; if we need to look in
	// be:filetypes, we'll reset these.

	int type_idx = 0;
	const char *field_name = "be:types";

	const char *target_mime = msg->FindString( field_name, type_idx );
	if( !strcasecmp( target_mime, B_FILE_MIME_TYPE ) ) {
		// If target_mime == B_FILE_MIME_TYPE then we should be checking
		// in be:filetypes... this will end up being written to a file.

		field_name = "be:filetypes";
		target_mime = msg->FindString( field_name, type_idx );
	}

	while( target_mime ) {
		// Can any of the Translators give us data in this type?  First
		// we'll need to convert the MIME type to a Translation Kit type
		// code.

		uint32 target_code = _Mime2TypeCode( roster, target_mime );

		if( target_code != 0 ) {
			// We've found a translation type; let's try translating the
			// data.

			_bits_mutex.Lock();

			BMallocIO *bit_buff = new BMallocIO;
			BBitmapStream bit_stream( _bits );

			status_t retval = roster->Translate( &bit_stream, NULL, NULL,
												 bit_buff, target_code );

			BBitmap *detached;
			(void)bit_stream.DetachBitmap( &detached );

			_bits_mutex.Unlock();

			if( retval == B_OK ) {
				// Successful translation!  Woo-hoo!
				//
				// Make a copy of the MIME type we translated to, and then
				// send back the data.

				*type_out = new char[strlen( target_mime ) + 1];
				strcpy( *type_out, target_mime );

				return bit_buff;
			} else {
				delete bit_buff;
			}
		}

		// That didn't work... let's try the next one.

		type_idx++;
		target_mime = msg->FindString( field_name, type_idx );
	}

	// If you got here, we didn't manage to translate the data.  Dang.

	*type_out = NULL;
	return NULL;
}