Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am writing a c++ program that should send some mails using SMTP. I need to send the server the AUTH PLAIN request, so I need to code my "\0user@domain.com\0password" to base64, so that I can send the full request. When I pass the "\0user@domain.com\0password" to any program that decodes to base64 I got nothing, because I am starting my string with null character.

Code for base64: http://www.adp-gmbh.ch/cpp/common/base64.html
I am using Visual Studio 2010 on Windows 8.

Could you help please.
Posted
Comments
KarstenK 15-Apr-15 7:28am    
To use "\0" in a string is wrong. Cant you use any other delimiter as "\n"?
TAREK BAZINGA 15-Apr-15 8:20am    
I think it is not wrong, but you can say useless. but that's what I want to do, to encode this string as it is to base64

take a look at https://rtcamp.com/tutorials/mail/server/testing/smtp/
Authentication part

You should use the
std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) 

function to encode your (binary) string.
 
Share this answer
 
Comments
TAREK BAZINGA 15-Apr-15 8:22am    
I already did it CPallini, but I got a false identification.
When I use AUTH LOGIN in telnet, it works very well, because I need to encode the username and the password separately, but with AUTH PLAIN, I need to encode '\0user@domain.com\0password'
Where are you getting the in_len parameter? If you get it from strlen(bytes_to_encode) you will get zero length, since that counts up to the first null character.

If you are sure the string is correctly formatted, you need to find the position of the third null, which indicates the end of the string. This will give the correct length.Or put it together using std::string, and get the length from that.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900