Skip to content

dataPaddingRequired exception #1007

Answered by jbg77
jbg77 asked this question in Q&A
Discussion options

You must be logged in to vote

Hello,

I think I have figured out the issue with my previous attempt to use the noPadding function in CryptoSwift. It seems that if there's no padding, the input needs to be a multiple of 16 bits.

I have updated my input array to include additional bytes so that it's a multiple of 16 bits, like this:
let input: Array<UInt8> = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] let encrypted: Array<UInt8> = try! AES(key: Array("secret0key000000".utf8), blockMode: CBC(iv: Array("0123456789012345".utf8)), padding: .noPadding).encrypt(input)

This code now works without throwing a CryptoSwift.AES.Error.dataPaddingRequired exception.

I hope this solution helps others who may encounter similar issues.

Best…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by jbg77
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants