wolves Posted August 9, 2006 Share Posted August 9, 2006 I need help to convert this function from c++ to php[code]long MontaChave(AnsiString chave, long seed){ union { long chave; unsigned char bytes[sizeof(long)]; } Buffer,Old; Buffer.chave = seed; Old.chave = seed; if (chave == "") { throw EConvertError("Chave para codificação não pode estar vazia"); } for(char *pos = chave.c_str(); *pos; pos++) { Buffer.bytes[0] ^= (unsigned char)~*pos; Buffer.bytes[1] ^= (unsigned char)~*pos; Buffer.bytes[2] ^= (unsigned char)~*pos; Buffer.bytes[3] ^= (unsigned char)~*pos; } if(!Buffer.bytes[0]) Buffer.bytes[0] = Old.bytes[0]; if(!Buffer.bytes[1]) Buffer.bytes[1] = Old.bytes[1]; if(!Buffer.bytes[2]) Buffer.bytes[2] = Old.bytes[2]; if(!Buffer.bytes[3]) Buffer.bytes[3] = Old.bytes[3]; return Buffer.chave;}[/code]AnsiString is a string bigger than type String Quote Link to comment Share on other sites More sharing options...
king arthur Posted August 9, 2006 Share Posted August 9, 2006 First, you might want to edit your post and remove the swearing before a moderator does it for you.Second, you're going to need to find a way to overcome PHP's lack of unions and pointers to convert this code. Also find out what type AnsiString is. Quote Link to comment Share on other sites More sharing options...
wolves Posted August 9, 2006 Author Share Posted August 9, 2006 [quote author=king arthur link=topic=103609.msg412663#msg412663 date=1155153112]First, you might want to edit your post and remove the swearing before a moderator does it for you.Second, you're going to need to find a way to overcome PHP's lack of unions and pointers to convert this code. Also find out what type AnsiString is.[/quote]sorry my english is bad and I don't know the meaning of """remove the swearing"""" ?pointers? u mean &$myvar?and AnsiString is a string bigger then type Stringtks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.