All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.simiacryptus.skyenet.util.EncryptFiles.kt Maven / Gradle / Ivy

There is a newer version: 1.2.21
Show newest version
package com.simiacryptus.skyenet.util

import com.simiacryptus.skyenet.core.platform.ApplicationServices
import java.io.File
import java.nio.file.Files
import java.nio.file.Paths

object EncryptFiles {

    @JvmStatic
    fun main(args: Array) {
        File("""C:\Users\andre\code\SkyeNet\webui\src\test\resources\client_secret_google_oauth.json""")
            .readText().encrypt("arn:aws:kms:us-east-1:470240306861:key/a1340b89-64e6-480c-a44c-e7bc0c70dcb1")
            .write("""C:\Users\andre\code\SkyeNet\webui\src\test\resources\client_secret_google_oauth.json.kms""")
    }

}

fun String.write(outpath: String) {
    Files.write(Paths.get(outpath), toByteArray())
}

fun String.encrypt(keyId: String) = ApplicationServices.cloud?.encrypt(encodeToByteArray(), keyId)
    ?: throw RuntimeException("Unable to encrypt data")




© 2015 - 2024 Weber Informatics LLC | Privacy Policy