# EncryptionProxy

Call the **EncryptionProxy** SPI to encrypt or decrypt sensitive data.

# Method signature

```java
public interface EncryptionProxy {
    String encrypt(String plainText);
    String decrypt(String cipherText);
}
```

# Request parameters

| **Item** | **Type** | **Parameters** | **Description** | **Required** |
| --- | --- | --- | --- | --- |
| String encrypt(String plainText) | Function | String plainText | This function is used to encrypt sensitive data. | Required |
| String decrypt(String cipherText) | Function | String cipherText | This function is used to decrypt sensitive data. | Required |

# Response parameters

| **Item** | **Type** | Description |
| --- | --- | --- |
| / | String | The encrypted sensitive data. |
| / | String | The decrypted sensitive data. |

# Sample

```kotlin
import com.iap.android.nfc.listener.spi.EncryptionProxy

class NFCDemoEncryptionProxy : EncryptionProxy {
    companion object {
        const val KEY = "1234560"
    }

    private fun String.xorEncryptAndDecrypt(): String {
        return mapIndexed { index, char ->
            val keyChar = KEY[index % KEY.length]
            (char.code xor keyChar.code).toChar()
        }.joinToString("")
    }

    override fun encrypt(p0: String?): String {
        p0 ?: return ""
        return p0.xorEncryptAndDecrypt()
    }

    override fun decrypt(p0: String?): String {
        p0 ?: return ""
        return p0.xorEncryptAndDecrypt()
    }

}
```