mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-12 21:07:27 +08:00
[F] Fix encryption
This commit is contained in:
@@ -10,14 +10,18 @@ import org.springframework.context.annotation.Scope
|
|||||||
import org.springframework.stereotype.Component
|
import org.springframework.stereotype.Component
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author samnyan (privateamusement@protonmail.com)
|
* A new decoder object will be created each time a new request comes in
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
||||||
class AimeDbDecoder : ByteToMessageDecoder() {
|
class AimeDbDecoder : ByteToMessageDecoder() {
|
||||||
var length = 0
|
var length: Int = 0
|
||||||
val logger: Logger = LoggerFactory.getLogger(AimeDbDecoder::class.java)
|
val logger: Logger = LoggerFactory.getLogger(AimeDbDecoder::class.java)
|
||||||
|
|
||||||
|
init {
|
||||||
|
logger.info("AimeDB Decoder Created")
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decrypt the incoming request including frame management
|
* Decrypt the incoming request including frame management
|
||||||
* @param ctx ChannelHandlerContext
|
* @param ctx ChannelHandlerContext
|
||||||
|
|||||||
@@ -12,9 +12,10 @@ import javax.crypto.spec.SecretKeySpec
|
|||||||
*/
|
*/
|
||||||
object AimeDbEncryption {
|
object AimeDbEncryption {
|
||||||
val KEY = SecretKeySpec("Copyright(C)SEGA".toByteArray(StandardCharsets.UTF_8), "AES")
|
val KEY = SecretKeySpec("Copyright(C)SEGA".toByteArray(StandardCharsets.UTF_8), "AES")
|
||||||
val cipher = Cipher.getInstance("AES/ECB/NoPadding").apply { init(Cipher.ENCRYPT_MODE, KEY) }
|
val enc = Cipher.getInstance("AES/ECB/NoPadding").apply { init(Cipher.ENCRYPT_MODE, KEY) }
|
||||||
|
val dec = Cipher.getInstance("AES/ECB/NoPadding").apply { init(Cipher.DECRYPT_MODE, KEY) }
|
||||||
|
|
||||||
fun decrypt(src: ByteBuf) = copiedBuffer(cipher.doFinal(ByteBufUtil.toBytes(src)))
|
fun decrypt(src: ByteBuf) = copiedBuffer(dec.doFinal(ByteBufUtil.toBytes(src)))
|
||||||
|
|
||||||
fun encrypt(src: ByteBuf) = copiedBuffer(cipher.doFinal(ByteBufUtil.toAllBytes(src)))
|
fun encrypt(src: ByteBuf) = copiedBuffer(enc.doFinal(ByteBufUtil.toAllBytes(src)))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user