Click here to Skip to main content
15,882,017 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
I don't know how to convert the int value to string message which can be encoded using formula in which the formula is using the int or long value!! how to encrypt(string data type) message instead direct using (int or long data type). if using those code with long datatype value, it just like calculate a mathematics value...And also... hopefully can decrypt the value back to the original message ... thank you!! Please Help!

[edit]removed urgency[/edit]
Posted
Updated 5-Nov-13 6:36am
v2
Comments
Richard MacCutchan 5-Nov-13 13:09pm    
This question does not make a lot of sense. If you are looking for encryption then Google will find you many samples.

As this is Windows, you can use Win32 Crypto API: http://msdn.microsoft.com/en-us/library/Windows/desktop/aa380255%28v=vs.85%29.aspx[^].

This CodeProject article could be useful: Encryption using the Win32 Crypto API[^].

I would understand if you prefer some open-source implementation. Look at this one at Google code: https://code.google.com/p/rsa/[^].

You can find some more: http://bit.ly/17DtcEg[^].

Finally, you can implement RSA from scratch based on description of the algorithm. You can find everything if you start here: http://en.wikipedia.org/wiki/RSA_%28algorithm%29[^].

—SA
 
Share this answer
 
Comments
Espen Harlinn 5-Nov-13 16:14pm    
5'ed! I liked Jessn short, and to the point, article on how to leverage the crypto API ;)
Sergey Alexandrovich Kryukov 5-Nov-13 18:12pm    
Right... Thank you, Espen.
—SA
Member 10381794 5-Nov-13 20:10pm    
thanks... i need to know any simple implementation, for example this is my message string msg="hello world"; in string data type, i can straightly static_cast<int>msg (note: I know static_cast here cannot be the one which can convert the msg datatype) the string then we can straightly use this message with int datatype to encrypt.
Sergey Alexandrovich Kryukov 5-Nov-13 20:17pm    
You need to convert the string to a raw byte array. If the string is Unicode, you will need to serialize it...
—SA
Just let me get some things straight, as it looks you are rather new to encryption.

You can encrypt both, text data or binary data, like an int or long int variable, or an array of those, or a structure with mixed text and binary data. The encryption algorithm does not care, it just take a certain number of bytes and encrypts them into (most often) the same number of bytes in a another buffer.

So if you have an int value that you want to encrypt, there is no need to convert it first to a string value.

As for how to apply encryption algorithms to an arbitrary buffer of bytes, the solution of Sergey has given you lots of hints. And there are many examples around that you can find via Google.
 
Share this answer
 
Try http://www.stringencrypt.com/[^] it helps you to encrypt the string and generates the decryption code in selected programming language.
 
Share this answer
 

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