All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pubnub.api.crypto.cryptor.CryptorHeader.kt Maven / Gradle / Ivy

Go to download

PubNub is a cross-platform client-to-client (1:1 and 1:many) push service in the cloud, capable of broadcasting real-time messages to millions of web and mobile clients simultaneously, in less than a quarter second!

There is a newer version: 10.2.0
Show newest version
package com.pubnub.api.crypto.cryptor

class CryptorHeader(
    val sentinel: ByteArray, // 4 bytes
    val version: Byte, // 1 byte
    val cryptorId: ByteArray, // 4 bytes
    val cryptorDataSize: ByteArray, // 1 or 3 bytes
    val cryptorData: ByteArray // 0-65535 bytes
) {

    fun toByteArray(): ByteArray {
        return sentinel + version + cryptorId + cryptorDataSize + cryptorData
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as CryptorHeader

        if (!sentinel.contentEquals(other.sentinel)) return false
        if (version != other.version) return false
        if (!cryptorId.contentEquals(other.cryptorId)) return false
        if (!cryptorDataSize.contentEquals(other.cryptorDataSize)) return false
        if (!cryptorData.contentEquals(other.cryptorData)) return false

        return true
    }

    override fun hashCode(): Int {
        var result = sentinel.contentHashCode()
        result = 31 * result + version
        result = 31 * result + cryptorId.contentHashCode()
        result = 31 * result + cryptorDataSize.contentHashCode()
        result = 31 * result + cryptorData.contentHashCode()
        return result
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy