iOS Question iEncryption AES noPadding Option

walterf25

Expert
Licensed User
Longtime User
I am trying to Encrypt some Data received via a BLE peripheral device, but there seems to be no "nopadding" option, below is my code so far, but I am actually converting parts of swift code project i have working.

AES Encryption:
Public Sub AESEncrypt(dataToEncrypt() As Byte, MyAESPW As String) As Byte()
    Dim md As MessageDigest
    Dim C As Cipher
    Dim bMD() As Byte = md.GetMessageDigest(MyAESPW.GetBytes("UTF8"),"MD5")
    Dim iOption As Int = Bit.Or(C.OPTION_PKCS7Padding,C.OPTION_ECBMode)
    Dim bData() As Byte = C.Encrypt2(dataToEncrypt,bMD,"AES",Null,iOption)
   Log("data size: " & bData.Length)

    Return bData
End Sub

The Encryption Code in Swift is the following
Swift Code:
Private static func Encode_AES_ECB(datatoEncode:Data, key:Data)throws -> Data{
    var encoded = Array<UInt8>()
    do{
        let aes = try AES(key: Padding.noPadding.add(to:key.bytes: AES.blockSize), blockMode: ECB())
        encoded =try aes.encrypt(datatoEncode.bytes)
    }catch{
        print(error.localizedDescription)
    }
    return Data(encoded)
}

How can i set the noPadding option in iEncryption Library?

Thanks,
Walter
 
Top