Kotlin

코틀린 키해쉬 구하기

Machine_웅 2021. 4. 30. 16:37
728x90
반응형
    fun get_sha() {
        try {
            val info = packageManager.getPackageInfo("패키지경로", PackageManager.GET_SIGNING_CERTIFICATES)
            val signature = info.signingInfo.apkContentsSigners

            for (signature in signature) {
                val md = MessageDigest.getInstance("SHA-1")
                md.update(signature.toByteArray())
                Log.e("KeyHash:", encodeToString(md.digest(), Base64.DEFAULT))
            }
        } catch (e: PackageManager.NameNotFoundException) {
            e.printStackTrace()
        } catch (e: NoSuchAlgorithmException) {
            e.printStackTrace()
        }
    }
728x90
반응형