Skip to content

AES support #62

@mylockerbiz

Description

@mylockerbiz

I have some legacy AES ECB encryption to deal with in the port to multiplatform. In the current android only app, things work great. going to multiplatform i need support for Desktop and WASM and eventually iOS.
Are there plans for this?

here is the current Android only code i am converting

import java.security.MessageDigest
import java.security.NoSuchAlgorithmException
import java.util.Arrays
import java.util.Base64
import javax.crypto.Cipher
import javax.crypto.spec.SecretKeySpec

object Encryption
{
private val TAG: String? = javaClass.simpleName
private var secretKey: SecretKeySpec? = null
private lateinit var key: ByteArray
private const val ALGORITHM = "AES_256/ECB/PKCS5Padding"

private fun prepareSecreteKey(myKey: String)
{
	var sha: MessageDigest?
	try
	{
		key = myKey.toByteArray(StandardCharsets.UTF_8)
		sha = MessageDigest.getInstance("SHA-256")
		key = sha.digest(key)
		key = Arrays.copyOf(key, 32)
		secretKey = SecretKeySpec(
				key, ALGORITHM
								 )
	}
	catch (e: NoSuchAlgorithmException)
	{
		e.printStackTrace()
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions