I want to get RSA Public Key which is used for AWS authentication. I have a Kotlin Code but am unable to find a similar code in Swift. Here is the code for Kotlin.
Please let me know if anyone has an idea
Thanks!
Kotlin code
private fun getPublicKey(n: String, e: String): RSAPublicKey {
val publicKeySpec = RSAPublicKeySpec(
BigInteger(1, Base64.getUrlDecoder().decode(n)),
BigInteger(1, Base64.getUrlDecoder().decode(e)),
)
return KeyFactory
.getInstance("RSA")
.generatePublic(publicKeySpec) as RSAPublicKey
}
2
Answers
Found the right solution for that after many tries and attempts. I have copied the data extension from Heimdall. It is helpful to combine modulus and exponent data.
Here is the complete code.
Example:
Output:
I found this in some of my projects, check it please.