Hi Shahram, This might not be what you mean, but the xor function is C/C++ is like:
int x = 6544654, y = 9684296; x ^= y; x now contains the xored value of x with y. For your strings, just do it byte by byte. Cheers, degski On 16 September 2012 12:21, Shahram <[email protected]> wrote: > "Dear Jay Jay > > Thanks for your quick reply. But What I want is close to what you suggest. > That's part of an SIP protocol with a "SHA256" hash function. I couldn't > find XOR function in Crypto++ with the specification that I've mentioned > before. Is it possible for you to help me in this way? Thanks again. > > On Sunday, September 16, 2012 12:00:02 AM UTC-7, Jay Jay wrote: >> >> I take it you want to encrypt a username with a password. Why roll your >> own? DefaultEncryptorWithMAC will do this for you: >> >> Use like: >> >> template < typename F > >> const string EncryptString ( const string& instr, const string& >> passPhrase ) { >> >> string outstr; >> >> try { >> >> DefaultEncryptorWithMAC Encryptor ( passPhrase.c_str ( ), new F ( >> new StringSink ( outstr ), false ) ); >> Encryptor.Put ( ( byte* ) instr.c_str ( ), instr.size ( ) ); >> Encryptor.MessageEnd ( ); >> } >> >> catch ( std::exception& e ) { >> >> cout << e.what ( ) << endl; >> >> exit ( 0 ); >> } >> >> return outstr; >> } >> >> Where F is either HexEncoder or Base64Encoder. >> >> So call >> >> const string encrypted_username ( EncryptString<Base64Encoder> ( >> username, password ) ); >> >> Cheers, >> >> >> degski >> >> On 16 September 2012 09:21, Shahram <[email protected]> wrote: >> >>> Dear All >>> >>> Would you please help me to know how can I have a function with the >>> following specification: >>> >>> Inputs: string username, password; >>> output string F(username, password) = username XOR hash (password) >>> where hash= SHA256 or anything else. >>> >>> And I need also to have and write the output down in hex . Thanks in >>> advance. >>> >>> Regards >>> Shahram >>> >>> -- >>> You received this message because you are subscribed to the "Crypto++ >>> Users" Google Group. >>> To unsubscribe, send an email to cryptopp-user...@**googlegroups.com. >>> More information about Crypto++ and this group is available at >>> http://www.cryptopp.com. >> >> >> >> >> -- >> "When I see a bird that walks like a duck and swims like a duck and >> quacks like a duck, I call that bird a duck." >> >> - *James Whitcomb Riley* >> >> -- > You received this message because you are subscribed to the "Crypto++ > Users" Google Group. > To unsubscribe, send an email to > [email protected]. > More information about Crypto++ and this group is available at > http://www.cryptopp.com. -- "When I see a bird that walks like a duck and swims like a duck and quacks like a duck, I call that bird a duck." - *James Whitcomb Riley* -- You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to [email protected]. More information about Crypto++ and this group is available at http://www.cryptopp.com.
