简体   繁体   English

C ++如何将名称硬编码为二进制

[英]C++ How to hard code name into binary

I have a project that I am working on and I currently have it working to enter my name > then it converts to hex > encrypts it > decrypts it > then prints it. 我有一个正在处理的项目,目前正在输入我的名字>转换为十六进制>加密>解密>然后打印它。 The problem is I need to hard code my name in binary instead of how it currently works. 问题是我需要用二进制将我的名字硬编码,而不是当前的工作方式。 I have no idea how to convert it. 我不知道如何转换它。

Here is the code snippet. 这是代码片段。 I apologize if I have entered the code wrong. 如果我输入的密码有误,我深表歉意。 First time posting. 第一次发布。

CfinalprAES ofinalprAES;
ofinalprAES.MakeKey("abcdefghabcdefgh", "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16, 16);
char szDataIn[80];

printf("Enter your Name: ");
scanf("%79s", szDataIn);

char szDataOut[17] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
ofinalprAES.EncryptBlock(szDataIn, szDataOut);
CharStr2HexStr((unsigned char*)szDataIn, szHex, 16);
printf("Hex of input: ");
cout << szHex << endl;
CharStr2HexStr((unsigned char*)szDataOut, szHex, 16);
printf("Encrypted: ");
cout << szHex << endl;
memset(szDataIn, 0, 16);
ofinalprAES.DecryptBlock(szDataOut, szDataIn);
CharStr2HexStr((unsigned char*)szDataIn, szHex, 16);
printf("Decrypted: ");
std::stringstream ss;
ss << szHex << endl;
printf("Hex to String: ");
cout << ss.str();

Simple hard coding: 简单的硬编码:

char szDataIn[80] = "Chris Bertsch";

If you want to make that a little bit more obfuscated, you can use hex representations of the characters in your name: 如果您想使它更加模糊,可以使用名称中字符的十六进制表示形式:

char szDataIn[80] = "\x43\x68\x72\x69\x73\x20\x42\x65\x72\x74\x73\x63\x68";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM