Skip to content

Commit 006346d

Browse files
committed
[BOOK-63] refactor: AES 복호화 시 IV 크기를 고정값(16바이트)으로 수정
1 parent 525ac23 commit 006346d

File tree

1 file changed

+3
-2
lines changed
  • core/datastore/src/main/kotlin/com/ninecraft/booket/core/datastore/security

1 file changed

+3
-2
lines changed

core/datastore/src/main/kotlin/com/ninecraft/booket/core/datastore/security/CryptoManager.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ class CryptoManager @Inject constructor() {
5656

5757
fun decrypt(encodedText: String): String {
5858
val combined = Base64.decode(encodedText, Base64.NO_WRAP)
59-
val iv = combined.copyOfRange(0, cipher.blockSize)
60-
val encrypted = combined.copyOfRange(cipher.blockSize, combined.size)
59+
val iv = combined.copyOfRange(0, IV_SIZE)
60+
val encrypted = combined.copyOfRange(IV_SIZE, combined.size)
6161
cipher.init(Cipher.DECRYPT_MODE, getKey(), IvParameterSpec(iv))
6262
val decryptedString = String(cipher.doFinal(encrypted))
6363
return decryptedString
@@ -69,5 +69,6 @@ class CryptoManager @Inject constructor() {
6969
private const val BLOCK_MODE = KeyProperties.BLOCK_MODE_CBC
7070
private const val PADDING = KeyProperties.ENCRYPTION_PADDING_PKCS7
7171
private const val TRANSFORMATION = "$ALGORITHM/$BLOCK_MODE/$PADDING"
72+
private const val IV_SIZE = 16 // AES IV는 항상 16바이트
7273
}
7374
}

0 commit comments

Comments
 (0)