Computer scienceProgramming languagesKotlinAdditional instrumentsCryptography and encoding

Hashing and security

Hashing the androids

Report a typo

Luke Skywalker wants to send a list of androids to the rebel band with a hash to ensure the integrity of the information due to the Empire's communication attacks.

We have a data class: data class Android(val name: String, val energy: Int).

Please complete fun calculateAndroidsHash(androids: List<Android>): String to obtain the hash using SHA-512. You must keep in mind that you must combine all the string values into one and then hash them.

Sample Input 1:

R2D2:100|C3PO:200

Sample Output 1:

ee47120c1f2fc594934b2acc4b8a1586e86915906f0ad60451ba90e181dd49f043e0c1a3baa82c56bd493b7d98630fa2f5f709a660bc82515965531ed7ec760d
Write a program in Kotlin
import java.security.MessageDigest

fun calculateAndroidsHash(androids: List<Android>): String {
// write your code here
// First create one string to contain all the android strings value in one
// the return the SHA-512 hash
}

Create a free account to access the full topic