ios - AES must have a fixed IV size of 16-bytes regardless key size -


hello using bbaes encrypt , decrypt code. getting error in line.

encrypteddata=[bb encrypteddatafromdata:[bb datafromstring:_secret encoding:bbaesdataencodingbase64] iv:[bb datafromstring:iv encoding:bbaesdataencodingbase64] key:hashkeydata options:bbaesencryptionoptionsincludeiv]; 

and error is

*** terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'aes must have fixed iv size of 16-bytes regardless key size.' 

this how create hashkeydata

hashkeydata=[bb keybyhashingpassword:_key keysize:bbaessaltdefaultlength]; 

please me. thanks

you converting iv string iv data calling

[bb datafromstring:iv encoding:bbaesdataencodingbase64] 

this give more or less 16 bytes, depending on iv why getting exception.

the function should use use ivfromstring:. uses md5 hash create nsdata instance 16 bytes.

encrypteddata=[bb encrypteddatafromdata:[bb datafromstring:_secret encoding:bbaesdataencodingbase64] iv:[bb ivstring:iv] key:hashkeydata options:bbaesencryptionoptionsincludeiv]; 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -