hi trying generate kind of nsstring pattern real string "abcdefgh" want take corresponding bytes using
nsdata *data=[mystring datausingencoding:nsutf8stringencoding] nslog(@"%d",[data bytes]); copy these values byte array , limit total array size 24bit.
then want create following pattern
"abcdefgh efghabcd hgfedcba" how can generate kind of key ?
please me
i think work. logic reversedstring taken this answer
#import "nsstring+customcrypto.h" @implementation nsstring (customcrypto) - (nsstring *)reversedstring{ nsmutablestring *reversedstring = [nsmutablestring stringwithcapacity:[self length]]; [self enumeratesubstringsinrange:nsmakerange(0,[self length]) options:(nsstringenumerationreverse | nsstringenumerationbycomposedcharactersequences) usingblock:^(nsstring *substring, nsrange substringrange, nsrange enclosingrange, bool *stop) { [reversedstring appendstring:substring]; }]; return [nsstring stringwithstring:reversedstring]; } - (nsstring *)splicedstring{ nsinteger index = [self length]/2; nsstring *substring = [self substringfromindex:index]; nsstring *secondstring = [self substringtoindex:index]; return [substring stringbyappendingstring:secondstring]; } - (nsstring *)customcryptostring{ nsstring *splicedstring = [self splicedstring]; nsstring *reversedstring = [self reversedstring]; return [nsstring stringwithformat:@"%@ %@ %@",self, splicedstring, reversedstring]; } call category method of string
nslog(@"%@",[@"abcdefgh" customcryptostring]); output : abcdefgh efghabcd hgfedcba
Comments
Post a Comment