# RSA like java.crypto

**URL:** https://discuss.kotlinlang.org/t/rsa-like-java-crypto/25501
**Category:** JavaScript
**Created:** [August 20, 2022, 7:25pm UTC](https://discuss.kotlinlang.org/t/rsa-like-java-crypto/25501 "2022-08-20T19:25:52Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![MisterAssm](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@MisterAssm](https://discuss.kotlinlang.org/u/MisterAssm)
#### Post date: [August 20, 2022, 7:25pm UTC](https://discuss.kotlinlang.org/t/rsa-like-java-crypto/25501/1 "2022-08-20T19:25:52Z")

</div>

I would like to know if there is a library or some way to encrypt information with Kotlin/JS, like the `Cipher` class from `javax.crypto` does

Exemple code **Only working with Kotlin/JVM**

```kotlin
        RSAPublicKeySpec(mr.toBigInteger(16), er.toBigInteger(16)).let {
            return Base64.getEncoder().encodeToString(Cipher.getInstance("RSA/ECB/PKCS1Padding")!!.apply {
                init(Cipher.ENCRYPT_MODE, keyFactory.generatePublic(it))
            }.doFinal(tempIv))
        }

```

> **Variables**
>
> ```
> val mr =
> "B99B77A3D72D3A29B4271FC7B7300E2F791EB8948174BE7B8024667E915446D4EEA0C2424B8D1EBF7E2DDFF94691C6E994E839225C627D140A8F1146D1B0B5F18A09BBD3D8F421CA1E3E4796B301EEBCCF80D81A32A1580121B8294433C38377083C5517D5921E8A078CDC019B15775292EFDA2C30251B1CCABE812386C893E5"
> val er = 
> "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010001"
> 
> ```
