포스트

지문인증

BiometricPrompt

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//BiometricPrompt //지문인증
biometricPrompt = BiometricPrompt(this, executor, object : BiometricPrompt.AuthenticationCallback() {
    override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
        super.onAuthenticationSucceeded(result)
        // 인증 성공 처리
    }

    override fun onAuthenticationFailed() {
        super.onAuthenticationFailed()
        // 인증 실패 처리
    }

    override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
        super.onAuthenticationError(errorCode, errString)
        // 인증 오류 처리
    }
})

promptInfo = BiometricPrompt.PromptInfo.Builder()
    .setTitle("지문 인증")
    .setSubtitle("지문을 사용하여 로그인하세요")
    .setNegativeButtonText("취소")
    .build()

biometricPrompt.authenticate(promptInfo)

1
2
3
4
5
6
7
8
9
10
//EncryptedSharedPreferences  //암호화된 데이터 저장
val sharedPreferences = EncryptedSharedPreferences.create(
    "user_credentials", // 파일 이름
    MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC), // MasterKey 생성
    this,
    EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, // 키 암호화 방식
    EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM // 값 암호화 방식
)

sharedPreferences.edit().putString("user_id", "exampleId").apply()

© . 일부 권리 보유

Powered by Jekyll with Chirpy theme