Open-source multiplayer game server compatible with the RuneScape client
https://www.openrs2.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
529 B
19 lines
529 B
package org.openrs2.crypto
|
|
|
|
import io.netty.buffer.ByteBuf
|
|
import io.netty.buffer.ByteBufUtil
|
|
import java.security.MessageDigest
|
|
|
|
public fun ByteBuf.sha1(): ByteArray {
|
|
return sha1(readerIndex(), readableBytes())
|
|
}
|
|
|
|
public fun ByteBuf.sha1(index: Int, len: Int): ByteArray {
|
|
val digest = MessageDigest.getInstance("SHA-1")
|
|
if (hasArray()) {
|
|
digest.update(array(), arrayOffset() + index, len)
|
|
} else {
|
|
digest.update(ByteBufUtil.getBytes(this, index, len, false))
|
|
}
|
|
return digest.digest()
|
|
}
|
|
|