DataChunk DESECBEncrypt(DataChunk messageChunk, Block key) { DataChunk cipherChunk = initDataChunk(messageChunk.iLength - messageChunk.iLength % 8 + 16); Block message = initBlock(64), cipher; KeySchedule k; int i; cipher = initBlock(64); k = DESKeySchedule(key); for (i = 0; i < messageChunk.iLength / 8; i++) { memcpy(message, messageChunk.block + 8 * i, 8); cipher = DESEncrypt(message, k); memcpy(cipherChunk.block + 8 * i, cipher, 8); } free(message); // If the length is not an integral multiple of 8. if (messageChunk.iLength % 8) { memcpy((message = initBlock(64)), messageChunk.block + 8 * i, messageChunk.iLength % 8); cipher = DESEncrypt(message, k); memcpy(cipherChunk.block + 8 * i, cipher, 8); } return (cipherChunk); }
int main(void) { DataChunk messageChunk = initDataChunk(200), cipherChunk, decryptChunk; Block key1 = initBlock(80), key2 = initBlock(80); fread(key1, 1, 8, stdin); fread(key2, 1, 8, stdin); fgets(messageChunk.block, 200, stdin); = inputString(stdin, 150);
void writeRoot(SUPER_BLOCK * superBlockP) { //只有初始化时才会调用到这个文件,通常是调用下面的读方法 //inodeP的inodeNumber就是0 INODE * inodeP = createINODE(_755_AUTHORITY_DIR_); // 默认drwxr-xr-x 755 int blockNumber = getFreeBlockNumber(superBlockPointer); BLOCK * blockP = getBlock(blockNumber); //INODE增加分配的扇区的记录 inodeMemAddBlock(inodeP, blockNumber); initBlock(blockP); freeBlock(blockP); writeINODE(inodeP); char str[32]; //添加父文件夹节点到当前文件夹 memset(str, 0, 32); strcpy(str, ".."); *(unsigned int*)(str+28) = inodeP->inodeNumber; inodeDirAddFile(inodeP, str, 32); //添加当前文件节点到当前文件夹 memset(str, 0, 32); strcpy(str, "."); *(unsigned int*)(str+28) = inodeP->inodeNumber; inodeDirAddFile(inodeP, str, 32); superBlockP->inode = inodeP; }
bool Hero::init() { if (!Entity::init()) { return false; } setState(NORMAL); //初始化状态 setHP(100); setSP(100); TP = 0; //初始化三大数据 m_mode = SHIELD; //初始化模式状态 velocityY = 0; //初始化水平和竖直方向的速度 faceto = false; inTheAir_flag = true; initSprite(); //初始化动画 initBlock(); //初始化碰撞框 CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("Audio/Cloak.ogg"); CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("Audio/Clock.ogg"); CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("Audio/e.ogg"); CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("Audio/ea.ogg"); CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("Audio/en.ogg"); CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("Audio/haaaaa.ogg"); CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("Audio/heng.ogg"); CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("Audio/kale.ogg"); CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("Audio/maxArmor.ogg"); CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("Audio/seiya.ogg"); CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("Audio/souyuken.ogg"); return true; }
int main(int argc, char *argv[]) { camera::Loc.moveTo(0, 200, 0); NewWorld.loadWorld(NULL); //³õʼ»¯äÖȾÏß³Ì if (!initThread(argc, argv)) { return -1; } //¼ÓÔØBlock initBlock(); renderGroup Test; renderGroup VAO; location TTT(0, 0, 0); unsigned int i = -1; while (IsRenderThreadStart) { //äÖȾ NewWorld.refreshVAO(); Sleep(1); } #ifdef _DEBUG _CrtDumpMemoryLeaks(); #endif }
bool GameScene::init() { do { CC_BREAK_IF(!LayerColor::initWithColor(Color4B(180, 170, 160, 255))); srand(time(nullptr)); auto visibleSize = Director::getInstance()->getVisibleSize(); auto origin = Director::getInstance()->getVisibleOrigin(); //背景 auto bg = LayerColor::create(Color4B::ORANGE, BACKGROUND_LENGTH, BACKGROUND_LENGTH); bg->setPosition(origin + Vec2(visibleSize)/2); //layer默认锚点不会影响坐标 bg->ignoreAnchorPointForPosition(false); this->addChild(bg, BACKGROUND_ZORDER, BACKGROUND_TAG); //循环添加格子背景 for (auto i = 0; i < BLOCK_COUNT; i++) { initBlock(i); } //随机产生两个块 createBlock(); createBlock(); //触摸事件 auto listener = EventListenerTouchOneByOne::create(); listener->onTouchBegan = [&](Touch *touch, Event *) { m_startPos = touch->getLocation(); return m_canMove; }; listener->onTouchEnded = CC_CALLBACK_2(GameScene::moveBlock, this); //第二个参数表示:以谁为事件优先级的参照,它的优先级最高 _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this); //创建遮罩层 auto propLayer = LayerColor::create(Color4B(100, 100, 100, 230)); auto lblMessage = Label::createWithTTF("", "Marker Felt.ttf", 48); lblMessage->setPosition(Vec2(propLayer->getContentSize())/2); lblMessage->setColor(Color3B::RED); propLayer->addChild(lblMessage, PROP_LAYER_LABEL_MESSAGE_ZORDER, PROP_LAYER_LABEL_MESSAGE_TAG); auto itemRestart = MenuItemLabel::create(Label::createWithTTF("RESTART", "Marker Felt.ttf", 36), CC_CALLBACK_1(GameScene::reStart, this)); itemRestart->setPosition(Vec2(propLayer->getContentSize()) / 2 + Vec2(0, -100)); itemRestart->setColor(Color3B::BLACK); auto menu = Menu::create(itemRestart, nullptr); menu->setPosition(Vec2::ZERO); propLayer->addChild(menu); this->addChild(propLayer, PROP_LAYER_ZORDER, PROP_LAYER_TAG); propLayer->setVisible(false); return true; } while (0); return false; }
void testDES() { Block message = initBlock(64); KeySchedule k1; Block key = (unsigned char*)"12345678"; Block cifer; memset(message, 0x01, 8); k1 = DESKeySchedule(key); cifer = DESEncrypt(message, k1); //17 c1 2b 68 ab 3a a1 4c }
Block takeHexInput() { Block key = initBlock(64); int i; for (i = 0; i < 8; i++) scanf("%x", & key[i]); return (key); }
void Hero::doJump(float dt) { int temp = getPositionY(); if (getMode() == LIGHTBLADE) { m_sprite->getAnimation()->play("SB_Up"); } else m_sprite->getAnimation()->play("Up"); setState(NORMAL); setPositionY(temp + 10); initBlock(); inTheAir_flag = true; finished = false; jumpMainFlag = false; //在此处确定修正待机动画 velocityY = 14; }
void Hero::drangonPunch() { CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("Audio/souyuken.ogg"); int temp = getPositionY(); setPositionY(temp + 10); setState(NORMAL); inTheAir_flag = true; initBlock(); velocityY = 10; if(faceto) velocityX = -2; else velocityX = 2; m_sprite->getAnimation()->play("DrangonPunch"); force = 120; this->scheduleOnce(schedule_selector(Hero::setAttackRect),0.1f); this->scheduleOnce(schedule_selector(Hero::refresh),0.6f); }
int main(void) { DataChunk messageChunk = initDataChunk(150), cipherChunk, decryptChunk; Block message = initBlock(64), cipher; Block key1, key2, IV; KeySchedule k1, k2; int i; key1 = takeHexInput(); key2 = takeHexInput(); k1 = DESKeySchedule(key1); k2 = DESKeySchedule(key2); /* message = inputString(stdin, 150); cipher = DES3Encrypt(message, k1, k2); printf("\n"); for (i = 0; i < 8; i++) printf("%x ", cipher[i]); printf("\n"); fwrite(DES3Decrypt(cipher, k1, k2), 1, 9, stdout); printf("\n"); */ // messageChunk.block = inputString(stdin, 150); messageChunk.iLength = strlen(messageChunk.block) + 1; cipherChunk = DESCBCEncrypt(messageChunk, key1); printf("\n"); for (i = 0; i < cipherChunk.iLength; i++) printf("%x ", cipherChunk.block[i]); printf("\n"); decryptChunk = DESCBCDecrypt(cipherChunk, key1); (decryptChunk.iLength)++; printf("%s", decryptChunk.block); // return (0); }
void init(string ip) { tcpclient = new CClientSocket(); remoteip = new CIpAddress(ip, 1234); Uint16 port=1234; udpclient=new CUdpSocket(port); if(udpclient==NULL) { cout<<"couldn't create udp endpoint\n"; exit(EXIT_FAILURE); } while(1) { if(!Connected) { if(tcpclient->Connect(*remoteip)) { if(tcpclient->Ok()) { Connected=true; cout<<"connected to server"<<endl; } } } else { break; } } initBlock(); sendHello(); background = new Background("img/background.bmp"); background->setCoords(0,0); winScreen = new Background("img/win.bmp"); winScreen->setCoords(0,0); loseScreen = new Background("img/lose.bmp"); loseScreen->setCoords(0,0); mainMusic = Mix_LoadMUS("sound/mainbgm.wav"); int totalScroll =0; }
/* * Class: edu_uw_apl_commons_tsk4j_filesys_FileSystem * Method: initNative * Signature: ()V */ JNIEXPORT void JNICALL Java_edu_uw_apl_commons_tsk4j_filesys_FileSystem_initNative (JNIEnv *env, jclass clazz) { jint status; status = initBlock( env ); if( status != JNI_OK ) return; status = initBlockWalk( env ); if( status != JNI_OK ) return; status = initMeta( env ); if( status != JNI_OK ) return; status = initName( env ); if( status != JNI_OK ) return; status = initFile( env ); if( status != JNI_OK ) return; status = initWalkFile( env ); if( status != JNI_OK ) return; status = initDirectory( env ); if( status != JNI_OK ) return; status = initDirectoryWalk( env ); if( status != JNI_OK ) return; status = initMetaWalk( env ); if( status != JNI_OK ) return; }
int main(int argc, char *argv[]) { if (argc > 2 && strcmp(argv[1], "-s") == 0) { int size; int valReturn = sscanf(argv[2], "%d", &size); if (valReturn != 1 || size < 2) { fprintf(stderr, "tfs_create -s need 1 argument :" " the size enter : %d is not CORRECT \n", size); return 1; } else { error er; disk_id *disk = malloc(sizeof(*disk)); if(disk==NULL){ er.val=1; er.message="ERROR MALLOC DISK in TFS_CREATE"; testerror(er); } char* nameFile; if (argc > 3) { //the user give a name to the file nameFile = argv[3]; } else { nameFile = "disk.tfs"; } er = createFile(nameFile); testerror(er); er = start_disk(nameFile, disk); testerror(er); int sizeInOctal = size * 1024; /* int i=0; for(i; i<sizeInOctal;i++){ fputc(45,r); } ftruncate(fileno(r) sizeInOctal); deplace le curseur a la position max-1 */ fseek(disk->fichier, (sizeInOctal - 1), SEEK_CUR); fputc(0, disk->fichier); //ecris un octet en position max //Il faut reouvrir le fichier en mode binaire apres avoir fait un fputc fseek(disk->fichier, 0, SEEK_CUR); stop_disk(*disk); er = start_disk(nameFile, disk); testerror(er); block *b; b = initBlock(); free(b->valeur[0]); b->valeur[0] = valueToNombre32bits(size); //b->valeur[1] = valueToNombre32bits(1);// there is 1 partition at first //b->valeur[2] = valueToNombre32bits(size-1); er=write_block(*disk, *b, 0); testerror(er); /* read_block(*disk,*b,0); printf("dans fonction afficahge de block apres read\n"); printBlock(b); */ er=stop_disk(*disk); testerror(er); freeBlock(b); freeDisk(disk); return 0; } } else { fprintf(stderr, "tfs_create need at minimum 1 argument :\n -s " "follow by the size ( a POSITIVE NUMBER)of " "the new tfs\n [name] is optional, it is the name of the tfs\n"); return 1; } return 0; }
int main( VOID ) { int i,j; void* p_mem_array[NUM_MEM_BLKS+1]; free_blocks = initBlock(NUM_MEM_BLKS); for ( i=0; i< NUM_MEM_BLKS; i++ ) { p_mem_array[i] = s_request_memory_block(); //rtx_dbug_out_char((CHAR)(i+48)); if (p_mem_array[i] == NULL) { rtx_dbug_outs((CHAR *) "Null pointer.\r\n"); } else if (p_mem_array[i] > 0x10200000) { rtx_dbug_outs((CHAR *) "Memory out of bound. \r\n"); } else { rtx_dbug_outs((CHAR *) "Request meory block: almost OK\r\n"); } /* int last; int remain = p_mem_array[i]; //int i = 0; while (remain != 0) { //rtx_dbug_out_char((CHAR)(last+48)); last = remain%10; remain = remain/10; rtx_dbug_out_char((CHAR)(last+48)); } rtx_dbug_outs((CHAR *) "\r\n"); p_mem_array[i]++; last; remain = p_mem_array[i]; //int i = 0; while (remain != 0) { //rtx_dbug_out_char((CHAR)(last+48)); last = remain%10; remain = remain/10; rtx_dbug_out_char((CHAR)(last+48)); } rtx_dbug_outs((CHAR *) "\r\n"); rtx_dbug_outs((CHAR *) "\r\n"); */ for(j=0; j<128/4; j++) { *((UINT32* )p_mem_array[i]+j) = (UINT32)0; } } for ( i=0; i< NUM_MEM_BLKS; i++ ) { int temp; temp = s_release_memory_block( p_mem_array[i] ); if (temp == 0 ) { rtx_dbug_outs((CHAR *) "Release memory block: OK\r\n"); } else { rtx_dbug_outs((CHAR *) "Release memory block: Failed \r\n"); } } /*rtx_dbug_outs((CHAR *) "\r\n"); for ( i=0; i< NUM_MEM_BLKS; i++ ) { int temp; temp = s_release_memory_block( p_mem_array[i] ); if (temp == 0 ) { rtx_dbug_outs((CHAR *) "Release memory block: OK\r\n"); } else { rtx_dbug_outs((CHAR *) "Release memory block: Failed \r\n"); } } for ( i=0; i< NUM_MEM_BLKS+1; i++ ) { p_mem_array[i] = s_request_memory_block(); //rtx_dbug_out_char((CHAR)(i+48)); if (p_mem_array[i] == NULL) { rtx_dbug_outs((CHAR *) "Null pointer.\r\n"); } else if (p_mem_array[i] > 0x10200000) { rtx_dbug_outs((CHAR *) "Memory out of bound. \r\n"); } else { rtx_dbug_outs((CHAR *) "Request meory block: almost OK\r\n"); } } */ return 0; }
LLeft* LLeft::createLLeft() { auto lleft = LLeft::create(); lleft->initBlock(); return lleft; }