• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ des函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中des函数的典型用法代码示例。如果您正苦于以下问题:C++ des函数的具体用法?C++ des怎么用?C++ des使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了des函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: reader

// static
void Serdes::DeserializeInfo(std::vector<int8_t> const & bytes, Info & result)
{
  MemReader reader(bytes.data(), bytes.size());
  NonOwningReaderSource source(reader);

  auto version = static_cast<int8_t>(Version::Unknown);
  ReadPrimitiveFromSource(source, version);
  if (version == static_cast<int8_t>(Version::V0))
  {
    try
    {
      // TODO: Use temporary object InfoV0 and implement method to convert it to Info,
      // TODO: when InfoV1 will be implemented.
      coding::DeserializerJson des(source);
      des(result);
    }
    catch (base::Json::Exception & ex)
    {
      LOG(LERROR, ("Cannot deserialize eye file. Exception:", ex.Msg(), "Version:", version,
                   "File content:", std::string(bytes.begin(), bytes.end())));
    }
    return;
  }

  MYTHROW(UnknownVersion, ("Unknown data version:", static_cast<int>(version)));
}
开发者ID:milchakov,项目名称:omim,代码行数:27,代码来源:eye_serdes.cpp


示例2: destests

static void
destests(void)
{
	des("", "");
	des("The quick brown fox jumps over the lazy dog",
	    "51551eab3ebab959553caaed64a3dd9c49f595a630c45cb7317332f8ade70308c4e97aeabbdc7f19");
	des("test des encryption",
	    "7ced9849bed3f7efc1686c89759bafa8");
}
开发者ID:RQZeng,项目名称:freetds,代码行数:9,代码来源:challenge.c


示例3: rfb_crypt

void rfb_crypt(CARD8 *dst_buf, CARD8 *src_buf, unsigned char *password)
{
  unsigned char key[8];

  memset(key, 0, 8);
  strncpy((char *)key, (char *)password, 8);
  deskey(key, EN0);
  des(src_buf, dst_buf);
  des(src_buf + 8, dst_buf + 8);
}
开发者ID:hanzhaogang,项目名称:chromium-1,代码行数:10,代码来源:rfblib.c


示例4: memset

/**
  * @brief  Build ethernet frame and send out.
  * @param  See below.
  * @retval Not sure.
  */
int enet_send
(
    /* Pointer to wireless network layer's environment structure. */
    wnet_envar_t *p_wnet, 

    /* Pointer to wireless network layer transfer information. */
    wnet_txinfo_t *txinfo, 

    /* Data address. */
    uint8_t *pdata, 

    /* Data length. */
    uint32_t length
)
{
    wnet_enet_header_st_ptr enet_header_ptr = NULL;

    
    /* Reserve room for ENET header. */
    pdata -= WNET_ENET_HEADER_ST_LEN;
    length += WNET_ENET_HEADER_ST_LEN;
    enet_header_ptr = (wnet_enet_header_st_ptr)pdata;

    /* Initialize enet frame header.  */
    memset(enet_header_ptr, 0, WNET_ENET_HEADER_ST_LEN);

    /* Set enet frame destination address and source address. */
    COPY_MAC_ADDR(enet_header_ptr->dest_address, BroadcastAddr);
    
    /* Mac address is bind to the CPU's unique ID */
    enet_header_ptr->src_address[0] = 0x00;
    enet_header_ptr->src_address[1] = 0x11;
    enet_header_ptr->src_address[2] = 0x22;
    enet_header_ptr->src_address[3] = des(2);
    enet_header_ptr->src_address[4] = des(1);
    enet_header_ptr->src_address[5] = des(0);


    switch (txinfo->protocol) 
    {
        case WNET_TRANS_PROT_DSMP:
        { 
            enet_header_ptr->ether_type = cv_ntohs(LLC_ETHERTYPE_DSMPv1);    break;
        }
    
        default:
        {
            OSAL_MODULE_DBGPRT(MODULE_NAME, OSAL_DEBUG_INFO, "Invalid protocol[0x%04x], dropped.\n", txinfo->protocol);
            return -1;
        }
    }
    
    return fp_send(p_wnet, txinfo, pdata, length);
}
开发者ID:gexueyuan,项目名称:muticus,代码行数:59,代码来源:app_wnet.c


示例5: des

void des(int y, int x)
{
    if(map[y][x]!=0)    return;
    map[y][x] = 1;
    //prtout(4,4);
    //printf("\n");
    des(y,x+1);
    des(y,x-1);
    des(y+1,x);
    des(y-1,x);
    return;
}
开发者ID:peter0749,项目名称:TOJ,代码行数:12,代码来源:q42.c


示例6: DREover

static void DREover(const unsigned char *ECMdata, unsigned char *DW)
{
    uchar key[8];
    if(ECMdata[2] >= (43+4) && ECMdata[40] == 0x3A && ECMdata[41] == 0x4B)
    {
        memcpy(key, &DESkeys[(ECMdata[42] & 0x0F) * 8], 8);

        doPC1(key);

        des(key, DES_ECS2_DECRYPT, DW); // even DW post-process
        des(key, DES_ECS2_DECRYPT, DW+8); // odd DW post-process
    };
};
开发者ID:r3dnax,项目名称:enigma2pc,代码行数:13,代码来源:reader-dre.c


示例7: vncEncryptBytes2

/*
 *   [email protected]
 *   Encrypt bytes[length] in memory using key.
 *   Key has to be 8 bytes, length a multiple of 8 bytes.
*/
void
vncEncryptBytes2(unsigned char *where, const int length, unsigned char *key) {
	int i, j;
	deskey(key, EN0);
	for (i = 0; i< 8; i++)
		where[i] ^= key[i];
	des(where, where);
	for (i = 8; i < length; i += 8) {
		for (j = 0; j < 8; j++)
			where[i + j] ^= where[i + j - 8];
		des(where + i, where + i);
	}
}
开发者ID:chiradeep,项目名称:CloudStack,代码行数:18,代码来源:vncauth.c


示例8: vncDecryptBytes

/*
 *   [email protected]
 *   Decrypt bytes[length] in memory using key.
 *   Key has to be 8 bytes, length a multiple of 8 bytes.
 */
void
vncDecryptBytes(unsigned char *where, const int length, const unsigned char *key) {
	int i, j;
	deskey((unsigned char*) key, DE1);
	for (i = length - 8; i > 0; i -= 8) {
		des(where + i, where + i);
		for (j = 0; j < 8; j++)
			where[i + j] ^= where[i + j - 8];
	}
	/* i = 0 */
	des (where, where);
	for (i = 0; i < 8; i++)
		where[i] ^= key[i];
}
开发者ID:FrantisekKlika,项目名称:UltraVncAsDll,代码行数:19,代码来源:vncauth.c


示例9: vncDecryptPasswdFromFile2

int
vncDecryptPasswdFromFile2(char *fname,
			  char *passwdFullControl, char *passwdViewOnly)
{
    FILE *fp;
    int i, ch;
    char passwd[16];

    if (strcmp(fname, "-") != 0) {
	if ((fp = fopen(fname,"r")) == NULL)
	    return 0;		/* Could not open the file */
    } else {
	fp = stdin;
    }

    for (i = 0; i < 16; i++) {
	ch = getc(fp);
	if (ch == EOF)
	    break;
	passwd[i] = ch;
    }

    if (fp != stdin)
	fclose(fp);

    if (i < 8)
	return 0;		/* Could not read eight bytes */

    deskey(s_fixedkey, DE1);

    /* Decoding first (full-control) password */
    if (passwdFullControl != NULL) {
	des(passwd, passwd);
	memcpy(passwdFullControl, passwd, 8);
	passwdFullControl[8] = '\0';
    }

    /* Decoding second (view-only) password if available */
    if (i == 16 && passwdViewOnly != NULL) {
	des(&passwd[8], &passwd[8]);
	memcpy(passwdViewOnly, &passwd[8], 8);
	passwdViewOnly[8] = '\0';
    }

    /* Destroying our copy of clear-text passwords */
    memset(passwd, 0, 16);

    return (i < 16) ? 1 : 2;
}
开发者ID:alerque,项目名称:fbvnc,代码行数:49,代码来源:vncauth.c


示例10: vncDecryptPasswdFromFile

char *
vncDecryptPasswdFromFile(char *fname)
{
    FILE *fp;
    int i, ch;
    unsigned char *passwd = (unsigned char *)malloc(9);

    if (strcmp(fname, "-") != 0) {
	if ((fp = fopen(fname,"r")) == NULL)
	    return NULL;
    } else {
	fp = stdin;
    }

    for (i = 0; i < 8; i++) {
	ch = getc(fp);
	if (ch == EOF)
	    break;
	passwd[i] = ch;
    }

    if (fp != stdin)
	fclose(fp);

    if (i != 8)                 /* Could not read eight bytes */
	return NULL;

    deskey(s_fixedkey, DE1);
    des(passwd, passwd);

    passwd[8] = 0;

    return (char *)passwd;
}
开发者ID:gvsurenderreddy,项目名称:AlmostVPNPro,代码行数:34,代码来源:vncauth.c


示例11: defined

void CLogOutputSink::writeLogMessage( String& strMsg )
{
    if ( strMsg.length() > 1 && strMsg[strMsg.length()-2] == '\r' )
        strMsg.erase(strMsg.length()-2,1);

    const char* szMsg = strMsg.c_str(); 

#if defined( OS_WINDOWS_DESKTOP )
		::OutputDebugStringA(szMsg);
#elif defined( OS_PLATFORM_MOTCE )
		::OutputDebugStringW(common::convertToStringW(strMsg).c_str());
#elif defined(OS_WP8)
		::OutputDebugStringA(szMsg);
#elif defined( OS_SYMBIAN )
        TPtrC8 des((const TUint8*)szMsg);
      	RDebug::RawPrint(des);
        return;
#endif

#if !defined( OS_PLATFORM_MOTCE )
    for( int n = 0; n < (int)strMsg.length(); n+= 100 )
        fwrite(szMsg+n, 1, min(100,strMsg.length()-n) , stdout );

    fflush(stdout);
#endif
}
开发者ID:CSanshulgandhi,项目名称:rhodes,代码行数:26,代码来源:RhoLogSink.cpp


示例12: switch

// original RMessage is supplied so that remote demux plugin can extract necessary details
// using DeMux utility
TInt CMMFIlbcDecoderIntfcDeMux::DoSendSlaveSyncCommandResultL(const RMmfIpcMessage& aMessage)
	{
	TMMFDevSoundCIMessageData data;
	TInt result = KErrGeneral;

	// decode message
	iUtility->GetSyncMessageDataL(aMessage, data);

	switch (data.iCommand)
		{
		case EMMFDevSoundCIIlbcDecoderIntfcGetComfortNoiseGeneration:
			{
			TPckgBuf<TBool> cng; 
			iUtility->ReadFromInputDesL(aMessage, &cng);

			result = DoGetComfortNoiseGenerationL(cng());

			TPckgBuf<TBool> des(cng());
			iUtility->WriteToOutputDesL(aMessage, des);

			break;
			}
		default:
			{
			User::Leave(KErrNotSupported);
			}
		}

	return result;
	}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:32,代码来源:ilbcdecoderconfigci.cpp


示例13: vec

//--------------------------------------------------------------
void testApp::update() {
	
	float t = (ofGetElapsedTimef()) * 0.9f;
	float div = 250.0;
	
	for (int i=0; i<NUM_BILLBOARDS; i++) {
		
		// noise 
		ofVec3f vec(ofSignedNoise(t, billboards.getVertex(i).y/div, billboards.getVertex(i).z/div),
								ofSignedNoise(billboards.getVertex(i).x/div, t, billboards.getVertex(i).z/div),
								ofSignedNoise(billboards.getVertex(i).x/div, billboards.getVertex(i).y/div, t));
		
		vec *= 10 * ofGetLastFrameTime();
		billboardVels[i] += vec;
		billboards.getVertices()[i] += billboardVels[i]; 
		billboardVels[i] *= 0.94f; 
    	billboards.setNormal(i,ofVec3f(12 + billboardSizeTarget[i] * ofNoise(t+i),0,0));
	}
	
	
	// move the camera around
	float mx = (float)mouseX/(float)ofGetWidth();
	float my = (float)mouseY/(float)ofGetHeight();
	ofVec3f des(mx * 360.0, my * 360.0, 0);
	cameraRotation += (des-cameraRotation) * 0.03;
	zoom += (zoomTarget - zoom) * 0.03;
	
}
开发者ID:andreasmuller,项目名称:RaspberryPiWorkshop,代码行数:29,代码来源:testApp.cpp


示例14: switch

// original RMessage is supplied so that remote demux plugin can extract necessary details
// using DeMux utility
TInt CMMFG711EncoderIntfcDeMux::DoSendSlaveSyncCommandResultL(const RMmfIpcMessage& aMessage)
	{
	TMMFDevSoundCIMessageData data;
	TInt result = KErrNone;

	// decode message
	iUtility->GetSyncMessageDataL(aMessage, data);

	switch (data.iCommand)
		{
		case EMMFDevSoundCIG711EncoderIntfcGetVadMode:
			{
			TPckgBuf<TBool> vadModeOn; 
			iUtility->ReadFromInputDesL(aMessage, &vadModeOn);

			result = DoGetVadMode(vadModeOn());

			TPckgBuf<TBool> des(vadModeOn());
			iUtility->WriteToOutputDesL(aMessage, des);

			break;
			}
		default:
			{
			User::Leave(KErrNotSupported);
			}
		}

	return result;
	}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:32,代码来源:g711encoderconfigci.cpp


示例15: RunTest

LOCAL_C void RunTest(TInt aSize)
	{
	const TInt KTestRunUs = KTestRunSeconds * 1000000;

	RThread t;
	TInt r=t.Create(KNullDesC,TestThread,0x1000,NULL,(TAny*)aSize);
	test(r==KErrNone);
	t.SetPriority(EPriorityLess);
	TRequestStatus s;
	t.Logon(s);
	t.Resume();
	ServerSem.Wait();
	test(Server.Handle() != KNullHandle);

	RMySession sess;
	TRequestStatus stat;
	test(sess.Connect(Server,stat) == KErrNone);
	User::WaitForRequest(stat);	// connected

	Count=0;
	TPtr8 des((TUint8*)Dest, 0, aSize);
	sess.Test(des);
	User::After(KTestRunUs);
	t.Kill(0);
	User::WaitForRequest(s);
	sess.Close();
	Server.Close();
	CLOSE_AND_WAIT(t);

	TInt us=10*KTestRunUs/Count;
	test.Printf(_L("%5d byte writes: %8d/%ds %4d.%01dus\n"),aSize,Count,KTestRunSeconds,us/10,us%10);
	}
开发者ID:kuailexs,项目名称:symbiandump-os1,代码行数:32,代码来源:t_ipcbm.cpp


示例16: SDes

void SDes(char orientation, char PlainText[8], char Key[8], char Encipher[8])
{
    char m[8];
    char k[8];

    m[0]=PlainText[7];
    m[1]=PlainText[6];
    m[2]=PlainText[5];
    m[3]=PlainText[4];
    m[4]=PlainText[3];
    m[5]=PlainText[2];
    m[6]=PlainText[1];
    m[7]=PlainText[0];

    k[0]=Key[7];
    k[1]=Key[6];
    k[2]=Key[5];
    k[3]=Key[4];
    k[4]=Key[3];
    k[5]=Key[2];
    k[6]=Key[1];
    k[7]=Key[0];

    if (orientation==0)  des(m,k);
    else undes(m,k);

    Encipher[0]=m[7];
    Encipher[1]=m[6];
    Encipher[2]=m[5];
    Encipher[3]=m[4];
    Encipher[4]=m[3];
    Encipher[5]=m[2];
    Encipher[6]=m[1];
    Encipher[7]=m[0];
}
开发者ID:sanikoyes,项目名称:cipher,代码行数:35,代码来源:tdes.c


示例17: main

int main(int argc, char* argv[])
{
	Maze m;
	Maze::Step src(1, 1), des(6, 5);
	std::cout<<(m.findPath(src, des) == true ? "find a path" : "No path") <<std::endl;
	Maze m1;
	m1.findAllPath(src, des);

	char a[12][20] = {
	    {L,L,L,L,L,L,L,L,L,L,L,L,L,L,L,L,L,L,L,L},
   	 	{L,L,L,L,L,L,L,L,L,L,L,L,L,L,W,L,L,L,L,L},
    	{L,L,W,W,L,L,L,L,L,L,L,L,L,L,L,L,L,L,L,L},
    	{L,L,W,W,L,L,L,L,L,L,L,L,L,L,L,L,L,L,L,L},
    	{L,L,L,L,L,L,L,L,L,L,L,L,L,L,L,L,L,L,L,L},
    	{L,L,L,L,L,L,L,W,W,L,L,L,L,L,L,L,L,L,L,L},
    	{L,L,L,L,L,L,L,L,W,W,L,L,L,L,L,L,L,L,L,L},
    	{L,L,L,L,L,L,L,L,L,W,W,W,L,L,L,L,L,L,L,L},
    	{L,L,L,L,L,L,L,L,L,L,W,W,W,W,W,W,L,L,L,L},
    	{L,L,L,L,L,L,L,L,L,L,W,W,W,W,W,W,L,L,L,L},
   	 	{L,L,L,L,L,L,L,L,L,L,W,W,W,W,W,W,L,L,L,L},
    	{L,L,L,L,W,W,L,L,L,L,W,W,W,W,W,W,L,L,L,L}
  	};
	Matrix ma(a);
	ma.changeW2O(5,8);
	std::cout<<"After change W to O"<<std::endl;
	ma.output();
	return 0;
}
开发者ID:Hiskyliu,项目名称:Interview-Algorithms,代码行数:28,代码来源:maze.cpp


示例18: decrypt_str

/*
    解密(若len不是16的倍数, 解密会失败, return 0)
    key--8字节密钥
    in--密文, 字符串
    len--密文长度, 应是16的倍数
    return--解密后的明文, 字符串. 外部使用后应首先判断是否为0; 若不为0, 应free  
*/
char * decrypt_str(unsigned char *key, char *in, int len)
{
    char *buf = 0;
    char *p = 0;
    int bufLen;
    int resident = len % 16;/*因为一个字节由两个16进制字符表示,而且每块是8个字节*/
    if (resident != 0)
        return 0;/*failed*/

    bufLen = len / 2;
    buf = (char *)malloc(bufLen+1);
    buf[bufLen] = '\0';
    /*转换十六进制字符串为字节数组*/
    hexStr2bytes(in, len, buf);

    p = buf;
    /*init key*/
    deskey_jp(key, DE1);
    while(p < (buf + bufLen)) {
        /*ECB decrypt*/
        des((unsigned char *)p, (unsigned char *)p);
        p = p + 8;
    }
    /*清除填充在末尾的0. 由于0与'\0'等值, 所以不必再清除*/
    
    return buf;
        
}
开发者ID:Hacker-One,项目名称:backdoor_rootkit,代码行数:35,代码来源:exdes.c


示例19: main

int main() {
    char *key = "browsers";
    unsigned char data[16];
    int j;
    FILE *in, *out;

    deskey(key, EN0);
    
    in = fopen("challenge", "r");
    if (!in) {
        printf("failed opening challenge\n");
        exit(1);
    }
    fread(data, 1, 16, in);
    fclose(in);

    for (j=0; j<16; j += 8) {
        des(data+j, data+j);
    }

    out = fopen("out", "w+");
    if (!out) {
        printf("failed opening out\n");
        exit(1);
    }
    fwrite(data, 1, 16, out);
    fclose(out);

    return 0;
}
开发者ID:HoTaeWang,项目名称:node-des,代码行数:30,代码来源:main.c


示例20: __KTRACE_OPT

void DMediaDriverFlashWin32::CompleteWrite()
//
// Do the actual write in the completion
// Transfer data in blocks from the client and AND it to the 'flash'
//
	{
	__KTRACE_OPT(KLOCDRV,Kern::Printf("Flash:WriteComplete"));

	TInt r = KErrNone;
	TUint8* flash = iBase + (TInt)iWriteReq->Pos();
	TInt len = (TInt)iWriteReq->Length();
	TInt offset = 0;
	while (len > 0)
		{
		TInt size = Min(len, KDataBufSize);
		TPtr8 des(iData,size);
		r = iWriteReq->ReadRemote(&des, offset);
		if (r!=KErrNone)
			break;
		len -= size;
		offset += size;
		const TUint8* ptr = iData;
		do
			{
			*flash++ &= *ptr++;
			} while (--size > 0);
		}

	if (iState == EWriting)
		iState = EIdle;
	Complete(EReqWrite,r);
	if (iState == ESuspended)
		StartErase();
	}
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:34,代码来源:lffsdev.cpp



注:本文中的des函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ des2src函数代码示例发布时间:2022-05-30
下一篇:
C++ dereference函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap