
com.pubnub.internal.crypto.cryptor.CryptorHeader.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pubnub-kotlin-impl Show documentation
Show all versions of pubnub-kotlin-impl Show documentation
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!
package com.pubnub.internal.crypto.cryptor
internal 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 - 2025 Weber Informatics LLC | Privacy Policy