SASDerivation.kt

517 B · raw

1package com.peachpasswords.sync23object SASDerivation {4    fun derive(handshakeHash: ByteArray): String {5        require(handshakeHash.size >= 4) { "Handshake hash too short" }6        val n = (((handshakeHash[0].toInt() and 0xFF) shl 24) or7                ((handshakeHash[1].toInt() and 0xFF) shl 16) or8                ((handshakeHash[2].toInt() and 0xFF) shl 8) or9                (handshakeHash[3].toInt() and 0xFF)).toLong() and 0xFFFFFFFFL10        return (n % 1_000_000L).toString().padStart(6, '0')11    }12}