반응형
Notice
Recent Posts
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 27 | 28 | 29 | 30 | 31 |
Tags
- Android
- git
- JNI
- mqtt
- Dva
- firebase-storage
- mosquitto
- google-login
- cloud-firestore
- Kotlin
- hung-up
- Flavors
- gradle
- Galaxy Watch
- AWS
- TIZEN
- 워치
- ozd
- 오즈뷰어
- Firebase
- OZViewer
- ActivityResult-API
- firebase-database
- NoSuchMethodError
- socket-server
- BottomSheetDialog
- socket-client
- Java8
- socket.io
- git-push
Archives
- Today
- Total
Hyeyeon blog
[Android] Kotlin- Encode Base64 & Encrypt SHA-512 본문
반응형
1. Encode Base64
- Base64.NO_WRAP : Base64 값의 마지막에 붙는 '\n'를 삭제
val target = "TEXT" val base64 = Base64.encodeToString(target.toByteArray(StandardCharsets.UTF_8), Base64.NO_WRAP)
2. Encrypt SHA-512
- MessageDigest algorighm으로 MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512 사용 가능
fun getEncrypt() : String{
val target = "TEXT"
val messageDigest = MessageDigest.getInstance("SHA-512")
val digest = md.digest(target .toByteArray())
val encryptedStr = StringBuilder()
for (i in digest.indices) {
sb.append(Integer.toString((digest[i] and 0xff.toByte()) + 0x100, 16).substring(1))
}
return encryptedStr
}
728x90
'개발 > Android' 카테고리의 다른 글
[Android] Databinding - EditText의 OnTextChanged() 구현 (0) | 2019.01.30 |
---|---|
[Android] Koin - Dependency Injection Library (0) | 2019.01.27 |
[Android] Kotlin - SMS Receiver (인증번호 받기) (0) | 2019.01.23 |
[Android] Kotlin - lateInit variable 초기화 여부 확인 (0) | 2019.01.22 |
[Android] Dependency Injection vs Service Locator (0) | 2019.01.22 |
Comments