ios - Remove spaces in SHA256 output -



ios - Remove spaces in SHA256 output -

can solve problem related sha256 in ios?

#import <commoncrypto/commondigest.h> nsdata *datain = [@"xxxxx" datausingencoding:nsasciistringencoding]; nsmutabledata *macout = [nsmutabledata datawithlength:cc_sha256_digest_length]; cc_sha256(datain.bytes, datain.length, macout.mutablebytes); nslog(@"datain: %@", datain); nslog(@"macout: %@", macout);

i getting output :

2014-10-14 10:46:43.602 sha256[480:70b] datain: <416e616e 64> 2014-10-14 10:46:43.604 sha256[480:70b] macout: <e9fb6a39 4db5ffd6 dba9b31a c7d9a90d 56f90767 afaf1e14 d6dcaa37 db180932>

what need need remove space in macout. i.e this

add below code:

nsstring *macoutstring = [nsstring stringwithformat:@"%@", macout]; nsstring *encryptedstring = [macoutstring stringbyreplacingoccurrencesofstring:@" " withstring:@""]; nslog(@"macout: %@", encryptedstring);

you can verify encryption - http://www.xorbin.com/tools/sha256-hash-calculator

ios encryption sha256

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -