Click here to Skip to main content
15,905,420 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: DES Encryption Pin
jkirkerx16-Dec-11 9:00
professionaljkirkerx16-Dec-11 9:00 
GeneralRe: DES Encryption Pin
Randor 16-Dec-11 9:41
professional Randor 16-Dec-11 9:41 
GeneralRe: DES Encryption Pin
jkirkerx16-Dec-11 10:31
professionaljkirkerx16-Dec-11 10:31 
GeneralRe: DES Encryption Pin
Randor 16-Dec-11 11:04
professional Randor 16-Dec-11 11:04 
GeneralRe: DES Encryption Pin
jkirkerx16-Dec-11 12:06
professionaljkirkerx16-Dec-11 12:06 
GeneralRe: DES Encryption Pin
Randor 16-Dec-11 13:25
professional Randor 16-Dec-11 13:25 
GeneralRe: DES Encryption Pin
jkirkerx17-Dec-11 8:05
professionaljkirkerx17-Dec-11 8:05 
GeneralRe: DES Encryption Pin
Randor 17-Dec-11 9:47
professional Randor 17-Dec-11 9:47 
Hey there,

jkirkerx wrote:
I'm trying to get a perfect match on my encryption program, so it matches my asp.net version. It looks like the code you approved actually works correctly, and I'm down to the Base64 part.


Excellent.

jkirkerx wrote:
Is there a difference between your Base64Encode function and the function on this page?

http://msdn.microsoft.com/en-us/library/dhx0d524.aspx[^]


If you are referring to the code sample in this post: Re: decrypting question[^]

Yeah... I remember helping that guy over a number of weeks and he was complaining about the Microsoft CryptBinaryToString function[^] appending two characters... a carriage return [CR] and line feed [LF] ... so the code sample I provided him removed those characters.

This would probably cause your strings to not match if the ASP version is doing the same... this is the code that removes the CRLF:

C++
TCHAR pByteLF = *(LPWORD)(lpszBase64 + dwResult -1);
TCHAR pByteCR = *(LPWORD)(lpszBase64 + dwResult -2);
if(pByteCR == 0x0D && pByteLF == 0x0A)
{
	*(LPWORD)(lpszBase64 + dwResult -2) = 0;
}


It looks like I was planning on making it optional to strip those characters... if you look at the function it contains a BOOL bStripCRLF

You could probably just finish the functionality that I left incomplete...

C++
if(TRUE == bStripCRLF)
{
	TCHAR pByteLF = *(LPWORD)(lpszBase64 + dwResult -1);
	TCHAR pByteCR = *(LPWORD)(lpszBase64 + dwResult -2);
	if(pByteCR == 0x0D && pByteLF == 0x0A)
	{
		*(LPWORD)(lpszBase64 + dwResult -2) = 0;
	}
}


Today is Saturday so I will be coding for the next few hours. If you like... show me a sample with key, initialization vector, and output along with desired output. Don't post the key you intend to use in final production. With this I might be able to see what is causing any discrepancies.

Best Wishes,
-David Delaune
GeneralRe: DES Encryption Pin
jkirkerx17-Dec-11 20:49
professionaljkirkerx17-Dec-11 20:49 
GeneralRe: DES Encryption Pin
Randor 18-Dec-11 3:55
professional Randor 18-Dec-11 3:55 
GeneralRe: DES Encryption Pin
jkirkerx18-Dec-11 8:32
professionaljkirkerx18-Dec-11 8:32 
GeneralRe: DES Encryption Pin
Randor 18-Dec-11 11:29
professional Randor 18-Dec-11 11:29 
GeneralRe: DES Encryption Pin
jkirkerx18-Dec-11 14:18
professionaljkirkerx18-Dec-11 14:18 
GeneralRe: DES Encryption Pin
Randor 19-Dec-11 6:19
professional Randor 19-Dec-11 6:19 
GeneralRe: DES Encryption Pin
jkirkerx19-Dec-11 8:06
professionaljkirkerx19-Dec-11 8:06 
GeneralRe: DES Encryption Pin
Randor 19-Dec-11 8:29
professional Randor 19-Dec-11 8:29 
GeneralRe: DES Encryption Pin
jkirkerx19-Dec-11 8:47
professionaljkirkerx19-Dec-11 8:47 
GeneralRe: DES Encryption Pin
jkirkerx19-Dec-11 9:30
professionaljkirkerx19-Dec-11 9:30 
GeneralRe: DES Encryption Pin
Randor 19-Dec-11 10:36
professional Randor 19-Dec-11 10:36 
GeneralRe: DES Encryption Pin
jkirkerx19-Dec-11 10:53
professionaljkirkerx19-Dec-11 10:53 
GeneralPerfect Match! Pin
jkirkerx19-Dec-11 12:13
professionaljkirkerx19-Dec-11 12:13 
GeneralRe: Perfect Match! Pin
Randor 19-Dec-11 14:03
professional Randor 19-Dec-11 14:03 
GeneralRe: Perfect Match! Pin
jkirkerx19-Dec-11 14:49
professionaljkirkerx19-Dec-11 14:49 
GeneralRe: DES Encryption Pin
jkirkerx16-Dec-11 7:59
professionaljkirkerx16-Dec-11 7:59 
AnswerSymmetric-key - Initialization Vector Pin
jkirkerx16-Dec-11 18:04
professionaljkirkerx16-Dec-11 18:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.