what is the equal padding for RSA/ECB/OAEPWithSHA-1AndMGF1Padding in Swift?

780 Views Asked by At

I use RSA for encrypt data and send to server, and I saw a java file to find out how Android encryption works and I find the padding that Android uses: "RSA/ECB/OAEPWithSHA-1AndMGF1Padding".

I use SwiftyRSA pod and I have .OAEP padding and I encrypt the data but the server can not decrypt.

I use a website (devglan.com) for online encrypt and decrypt for testing.

The situation is that:

  1. I can encrypt data with this website and decrypt on server,
  2. I can encrypt data in my app and decrypt in website (not server)
  3. when I encrypt data in my app, the server can't decrypt data

I checked with server guy and they showed me the result of decrypt and it was null. I sent data with Postman for test and the response was successful.

My encryption code is:

let PublicKey = try! PublicKey(base64Encoded: PublicKeyString)
let clear = try! ClearMessage(string: "my text", using: .utf8)
let encrypted = try! clear.encrypted(with:publicKey1, padding:.OAEP)
     
let data = encrypted.data
let EncodeBase64Data = data.base64EncodedString()
0

There are 0 best solutions below