数据流加密技术

/*
原理:
给一个long,得到它的地址,依次取后面四个字节转化为整型作为ip
*/
#include <iostream>
using namespace std;

char* convertLongToIP(long ip, char* ch)
{
	unsigned char* c = (unsigned char*)&ip;
	sprintf(ch, "https://%d.%d.%d.%d:4689", c[3], c[2], c[1], c[0]);
	return ch;
}


void main()
{
	long ip = 1507077584L;
	char* c1 = (char*)malloc(64*sizeof(char));  //一个整形有4个字节,一个字节8位,即32位
    //cout<<sizeof(c1)<<endl;
    //for(int i = 0; i < 64; i++)
	//   cout<<c1[i]<<endl;
	convertLongToIP(ip, c1);
	printf("%s\n", c1);
	free(c1);
}

/*
https://89.212.45.208:4689
*/

你可能感兴趣的:(数据流加密技术)