refactor: type CardConv module
This commit is contained in:
parent
9a740008ea
commit
72ab3d7f6c
176
android/app/src/main/java/tk/nulldori/eamemu/A.kt
Normal file
176
android/app/src/main/java/tk/nulldori/eamemu/A.kt
Normal file
@ -0,0 +1,176 @@
|
||||
package tk.nulldori.eamemu
|
||||
|
||||
import java.io.UnsupportedEncodingException
|
||||
import kotlin.experimental.xor
|
||||
|
||||
class A {
|
||||
private var a: B? = null
|
||||
|
||||
init {
|
||||
try {
|
||||
this.a = B("?I\'llB2c.YouXXXeMeHaYpy!".toByteArray(charset("US-ASCII")))
|
||||
} catch (v0: UnsupportedEncodingException) {
|
||||
throw RuntimeException(v0)
|
||||
}
|
||||
|
||||
}
|
||||
private val validCharacters = "0123456789ABCDEFGHJKLMNPRSTUWXYZ"
|
||||
|
||||
fun toKonamiID(arg11: String): String {
|
||||
if (arg11.length != 16) {
|
||||
throw RuntimeException("Invalid UID length")
|
||||
}
|
||||
return when {
|
||||
arg11.toUpperCase().startsWith("E004") -> toKonamiID(arg11, 1.toByte())
|
||||
arg11.toUpperCase().startsWith("0") -> toKonamiID(arg11, 2.toByte())
|
||||
else -> throw RuntimeException("Invalid UID prefix")
|
||||
}
|
||||
}
|
||||
|
||||
fun toKonamiID(arg11: String, card_type: Byte): String {
|
||||
var v3: ByteArray
|
||||
val v9 = 13
|
||||
val v8 = 16
|
||||
val v7 = 8
|
||||
var v0 = 0
|
||||
try {
|
||||
v3 = E.a(arg11 as CharSequence)
|
||||
} catch (v0_1: Exception) {
|
||||
throw IllegalArgumentException(v0_1 as Throwable)
|
||||
}
|
||||
|
||||
if (v3.size != v7) {
|
||||
throw IllegalArgumentException("KONAMI ID should be 8 bytes, not " + v3.size)
|
||||
}
|
||||
|
||||
var v4 = ByteArray(v7)
|
||||
var v1: Int
|
||||
v1 = 0
|
||||
while (v1 < v7) {
|
||||
v4[7 - v1] = v3[v1]
|
||||
++v1
|
||||
}
|
||||
|
||||
v3 = this.a!!.a(v4)
|
||||
v4 = ByteArray(65)
|
||||
v1 = 0
|
||||
while (v1 < 64) {
|
||||
v4[v1] = (v3[v1 shr 3].toInt() shr (v1 xor -1 and 7) and 1).toByte()
|
||||
++v1
|
||||
}
|
||||
|
||||
v3 = ByteArray(v8)
|
||||
v1 = 0
|
||||
while (v1 < v9) {
|
||||
v3[v1] = (v4[v1 * 5].toInt() shl 4 and 255 or (v4[v1 * 5 + 1].toInt() shl 3 and 255) or (v4[v1 * 5 + 2].toInt() shl 2 and 255) or (v4[v1 * 5 + 3].toInt() shl 1 and 255) or (v4[v1 * 5 + 4].toInt() and 255)).toByte()
|
||||
++v1
|
||||
}
|
||||
|
||||
v3[v9] = 1
|
||||
v3[0] = (v3[0].toInt() xor card_type.toInt()).toByte()
|
||||
v1 = 1
|
||||
while (v1 < 14) {
|
||||
v3[v1] = v3[v1] xor v3[v1 - 1]
|
||||
++v1
|
||||
}
|
||||
|
||||
v3[14] = card_type
|
||||
v3[15] = calculate_checksum(v3).toByte()
|
||||
val v1_1 = CharArray(v8)
|
||||
while (v0 < v8) {
|
||||
v1_1[v0] = "0123456789ABCDEFGHJKLMNPRSTUWXYZ".get(v3[v0].toInt())
|
||||
++v0
|
||||
}
|
||||
|
||||
return String(v1_1)
|
||||
}
|
||||
|
||||
fun toUID(str: String): String {
|
||||
return when(str[14]) {
|
||||
'1' -> toUID(str, 1.toByte())
|
||||
'2' -> toUID(str, 2.toByte())
|
||||
else -> throw RuntimeException("Invalid Konami ID")
|
||||
}
|
||||
}
|
||||
|
||||
fun toUID(str: String, card_type: Byte): String {
|
||||
if (str.length != 16) {
|
||||
throw RuntimeException("KONAMI ID should be 16 characters, not ${str.length}")
|
||||
}
|
||||
val bArr = ByteArray(16)
|
||||
for (i in 0 until 16) {
|
||||
val index = validCharacters.indexOf(str[i])
|
||||
if (index >= 0) {
|
||||
bArr[i] = index.toByte()
|
||||
}
|
||||
else {
|
||||
throw RuntimeException("KONAMI ID entered is not Upper Alpha Numeric. See character $i")
|
||||
}
|
||||
}
|
||||
return toUID(bArr, card_type)
|
||||
}
|
||||
|
||||
fun toUID(bArr: ByteArray) = toUID(bArr.copyOf(), bArr[14])
|
||||
|
||||
private fun toUID(bArr: ByteArray, card_type: Byte): String {
|
||||
|
||||
if (bArr[11] % 2 != bArr[12] % 2) {
|
||||
throw RuntimeException("Wrong parity")
|
||||
}
|
||||
if (bArr[13] != bArr[12] xor 1) {
|
||||
throw RuntimeException("14th character must be 13th character xor 1")
|
||||
}
|
||||
if (bArr[14] == card_type && bArr[15].toInt() == calculate_checksum(bArr)) {
|
||||
var i2 = 13
|
||||
while (i2 > 0) {
|
||||
bArr[i2] = (bArr[i2].toInt() xor bArr[i2 - 1].toInt()).toByte()
|
||||
i2--
|
||||
}
|
||||
bArr[0] = (bArr[0].toInt() xor card_type.toInt()).toByte()
|
||||
var bArr2 = ByteArray(64)
|
||||
i2 = 0
|
||||
while (i2 < 64) {
|
||||
bArr2[i2] = (bArr[i2 / 5].toInt() shr 4 - i2 % 5 and 1).toByte()
|
||||
i2++
|
||||
}
|
||||
var bArr3 = ByteArray(8)
|
||||
i2 = 0
|
||||
while (i2 < 64) {
|
||||
val i3 = i2 / 8
|
||||
bArr3[i3] = (bArr3[i3].toInt() or (bArr2[i2].toInt() shl (i2 xor -1 and 7)).toByte().toInt()).toByte()
|
||||
i2++
|
||||
}
|
||||
bArr2 = this.a!!.b(bArr3)
|
||||
bArr3 = ByteArray(8)
|
||||
i2 = 0
|
||||
while (i2 < 8) {
|
||||
bArr3[i2] = bArr2[7 - i2]
|
||||
i2++
|
||||
}
|
||||
val prefix = bArr3[0].toInt() and 0xFF shl 8 or (bArr3[1].toInt() and 0xFF)
|
||||
if (card_type.toInt() == 1 && prefix == 0xE004 || card_type.toInt() == 2 && (prefix and 0xF000 == 0)) {
|
||||
return E.a(bArr3)
|
||||
}
|
||||
//throw RuntimeException("Decoding failed: Prefix ${prefix.toString(16)} does not match card type.")
|
||||
return "" // Exceptions are slow, so return an empty string here instead
|
||||
//throw new RuntimeException("Sanity check error, KONAMI ID does not decode to ICODE with NXP chip");
|
||||
}
|
||||
throw RuntimeException("Invalid Checksum")
|
||||
}
|
||||
fun calculate_checksum(arg4: ByteArray): Int {
|
||||
var v0 = 0
|
||||
var v1 = 0
|
||||
while (v1 < 15) {
|
||||
val v2 = (v1 % 3 + 1) * arg4[v1] + v0
|
||||
++v1
|
||||
v0 = v2
|
||||
}
|
||||
|
||||
while (v0 >= 32) {
|
||||
v0 = v0.ushr(5) + (v0 and 31)
|
||||
}
|
||||
|
||||
return v0
|
||||
}
|
||||
}
|
||||
|
185
android/app/src/main/java/tk/nulldori/eamemu/B.kt
Normal file
185
android/app/src/main/java/tk/nulldori/eamemu/B.kt
Normal file
@ -0,0 +1,185 @@
|
||||
package tk.nulldori.eamemu
|
||||
|
||||
class B(arg4: ByteArray) {
|
||||
private val k: IntArray
|
||||
|
||||
init {
|
||||
this.k = IntArray(96)
|
||||
if (arg4.size != 24) {
|
||||
throw IllegalArgumentException("Key was not 24 bytes, instead was " + arg4.size)
|
||||
}
|
||||
|
||||
this.a(arg4, 0, 0)
|
||||
this.a(arg4, 8, 32)
|
||||
this.a(arg4, 16, 64)
|
||||
}
|
||||
|
||||
fun a(arg5: ByteArray): ByteArray {
|
||||
val v1 = 8
|
||||
if (arg5.size != v1) {
|
||||
throw IllegalArgumentException("Input was not 8 bytes long, instead was " + arg5.size)
|
||||
}
|
||||
|
||||
val v0 = ByteArray(v1)
|
||||
a(v0, this.a(0, c(arg5)))
|
||||
a(v0, this.b(32, c(v0)))
|
||||
a(v0, this.a(64, c(v0)))
|
||||
return v0
|
||||
}
|
||||
|
||||
private fun a(arg9: ByteArray, arg10: Int, arg11: Int) {
|
||||
val v4 = ByteArray(56)
|
||||
var v2: Int
|
||||
v2 = 0
|
||||
while (v2 < 8) {
|
||||
var v0: Int
|
||||
v0 = 0
|
||||
while (v0 < 7) {
|
||||
v4[55 - v2 * 7 - v0] = (arg9[arg10 + v2].toInt()ushr(v0) and 1).toByte()
|
||||
++v0
|
||||
}
|
||||
++v2
|
||||
}
|
||||
var v0: Int
|
||||
|
||||
v0 = 0
|
||||
while (v0 < 32) {
|
||||
v2 = 0
|
||||
var v3: Int
|
||||
v3 = 0
|
||||
while (v3 < 24) {
|
||||
v2 = v2 or (v4[a!![v0 * 24 + v3].toInt()].toInt() shl b!![(v0 and 1) * 24 + v3].toInt())
|
||||
++v3
|
||||
}
|
||||
|
||||
this.k[arg11 + v0] = v2
|
||||
++v0
|
||||
}
|
||||
}
|
||||
|
||||
private fun a(arg10: Int, arg11: Long): Long {
|
||||
val v8 = 28
|
||||
val v7 = 32
|
||||
var v0 = arg11.ushr(v7).toInt()
|
||||
var v2 = arg11.toInt()
|
||||
var v1: Int
|
||||
v1 = 0
|
||||
while (v1 < v7) {
|
||||
var v3 = a(this.k[arg10 + v1 + 1] xor v0, v8)
|
||||
v2 = v2 xor (j[v3.ushr(2) and 63] xor (g[v3.ushr(26) and 63] xor h[v3.ushr(18) and 63] xor i[v3.ushr(10) and 63]) xor c[(this.k[arg10 + v1] xor v0).ushr(26) and 63] xor d[(this.k[arg10 + v1] xor v0).ushr(18) and 63] xor e[(this.k[arg10 + v1] xor v0).ushr(10) and 63] xor f[(this.k[arg10 + v1] xor v0).ushr(2) and 63])
|
||||
v3 = a(this.k[arg10 + v1 + 3] xor v2, v8)
|
||||
v0 = v0 xor (j[v3.ushr(2) and 63] xor (g[v3.ushr(26) and 63] xor h[v3.ushr(18) and 63] xor i[v3.ushr(10) and 63]) xor c[(this.k[arg10 + v1 + 2] xor v2).ushr(26) and 63] xor d[(this.k[arg10 + v1 + 2] xor v2).ushr(18) and 63] xor e[(this.k[arg10 + v1 + 2] xor v2).ushr(10) and 63] xor f[(this.k[arg10 + v1 + 2] xor v2).ushr(2) and 63])
|
||||
v1 += 4
|
||||
}
|
||||
|
||||
return v0.toLong() shl v7 or (v2.toLong() and 4294967295L)
|
||||
}
|
||||
|
||||
fun b(arg5: ByteArray): ByteArray {
|
||||
val v1 = 8
|
||||
if (arg5.size != v1) {
|
||||
throw IllegalArgumentException("Input was not 8 bytes long, instead was " + arg5.size)
|
||||
}
|
||||
|
||||
val v0 = ByteArray(v1)
|
||||
a(v0, this.b(64, c(arg5)))
|
||||
a(v0, this.a(32, c(v0)))
|
||||
a(v0, this.b(0, c(v0)))
|
||||
return v0
|
||||
}
|
||||
|
||||
private fun b(arg11: Int, arg12: Long): Long {
|
||||
val v9 = 28
|
||||
val v8 = 32
|
||||
var v0 = arg12.ushr(v8).toInt()
|
||||
var v2 = arg12.toInt()
|
||||
var v1: Int
|
||||
v1 = 0
|
||||
while (v1 < v8) {
|
||||
var v3 = a(this.k[arg11 + 31 - v1] xor v0, v9)
|
||||
v2 = v2 xor (j[v3.ushr(2) and 63] xor (c[(this.k[arg11 + 30 - v1] xor v0).ushr(26) and 63] xor d[(this.k[arg11 + 30 - v1] xor v0).ushr(18) and 63] xor e[(this.k[arg11 + 30 - v1] xor v0).ushr(10) and 63] xor f[(this.k[arg11 + 30 - v1] xor v0).ushr(2) and 63] xor g[v3.ushr(26) and 63] xor h[v3.ushr(18) and 63] xor i[v3.ushr(10) and 63]))
|
||||
v3 = a(this.k[arg11 + 29 - v1] xor v2, v9)
|
||||
v0 = v0 xor (j[v3.ushr(2) and 63] xor (c[(this.k[arg11 + 28 - v1] xor v2).ushr(26) and 63] xor d[(this.k[arg11 + 28 - v1] xor v2).ushr(18) and 63] xor e[(this.k[arg11 + 28 - v1] xor v2).ushr(10) and 63] xor f[(this.k[arg11 + 28 - v1] xor v2).ushr(2) and 63] xor g[v3.ushr(26) and 63] xor h[v3.ushr(18) and 63] xor i[v3.ushr(10) and 63]))
|
||||
v1 += 4
|
||||
}
|
||||
|
||||
return v0.toLong() shl v8 or (v2.toLong() and 4294967295L)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private var a: ByteArray? = null
|
||||
private var b: ByteArray? = null
|
||||
private val c: IntArray
|
||||
private val d: IntArray
|
||||
private val e: IntArray
|
||||
private val f: IntArray
|
||||
private val g: IntArray
|
||||
private val h: IntArray
|
||||
private val i: IntArray
|
||||
private val j: IntArray
|
||||
|
||||
init {
|
||||
a = byteArrayOf(0x22, 0xd, 0x5, 0x2e, 0x2f, 0x12, 0x20, 0x29, 0xb, 0x35, 0x21, 0x14, 0xe, 0x24, 0x1e, 0x18, 0x31, 0x2, 0xf, 0x25, 0x2a, 0x32, 0x0, 0x15, 0x26, 0x30, 0x6, 0x1a, 0x27, 0x4, 0x34, 0x19, 0xc, 0x1b, 0x1f, 0x28, 0x1, 0x11, 0x1c, 0x1d, 0x17, 0x33, 0x23, 0x7, 0x3, 0x16, 0x9, 0x2b, 0x29, 0x14, 0xc, 0x35, 0x36, 0x19, 0x27, 0x30, 0x12, 0x1f, 0x28, 0x1b, 0x15, 0x2b, 0x25, 0x0, 0x1, 0x9, 0x16, 0x2c, 0x31, 0x2, 0x7, 0x1c, 0x2d, 0x37, 0xd, 0x21, 0x2e, 0xb, 0x6, 0x20, 0x13, 0x22, 0x26, 0x2f, 0x8, 0x18, 0x23, 0x24, 0x1e, 0x3, 0x2a, 0xe, 0xa, 0x1d, 0x10, 0x32, 0x37, 0x22, 0x1a, 0x26, 0xb, 0x27, 0x35, 0x5, 0x20, 0x2d, 0x36, 0x29, 0x23, 0x2, 0x33, 0xe, 0xf, 0x17, 0x24, 0x3, 0x8, 0x10, 0x15, 0x2a, 0x6, 0xc, 0x1b, 0x2f, 0x1f, 0x19, 0x14, 0x2e, 0x21, 0x30, 0x34, 0x4, 0x16, 0x7, 0x31, 0x32, 0x2c, 0x11, 0x1, 0x1c, 0x18, 0x2b, 0x1e, 0x9, 0xc, 0x30, 0x28, 0x34, 0x19, 0x35, 0x26, 0x13, 0x2e, 0x6, 0xb, 0x37, 0x31, 0x10, 0xa, 0x1c, 0x1d, 0x25, 0x32, 0x11, 0x16, 0x1e, 0x23, 0x1, 0x14, 0x1a, 0x29, 0x4, 0x2d, 0x27, 0x22, 0x1f, 0x2f, 0x5, 0xd, 0x12,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15, 0x8, 0x2a, 0x2d, 0x35, 0x14, 0x4, 0x5, 0x21, 0x2f, 0x34, 0x1a, 0xb, 0x30, 0x1f, 0x3, 0x31, 0x2b, 0x25, 0x7, 0xf, 0x1c, 0x32, 0x0, 0x8, 0x2c, 0xa, 0x19, 0x6, 0x2e, 0x29, 0x36, 0x13, 0x27, 0x28, 0x1b, 0x26, 0x12, 0x37, 0xe, 0x1e, 0x11, 0x2a, 0x24, 0x9, 0x18, 0x33, 0x10, 0x23, 0x16, 0x1, 0x6, 0x26, 0x22, 0x12, 0x13, 0x2f, 0x4, 0xd, 0x28, 0x19, 0x5, 0x2d, 0x11, 0x8, 0x2, 0x33, 0x15, 0x1d, 0x2a, 0x9, 0xe, 0x16, 0x3, 0x18, 0x27, 0x14, 0x1f, 0x37, 0xb, 0x21, 0x35, 0x36, 0x29, 0x34, 0x20, 0xc, 0x1c, 0x2c, 0x0, 0x1, 0x32, 0x17, 0x7, 0xa, 0x1e, 0x31, 0x24, 0xf, 0x14, 0x34, 0x30, 0x20, 0x21, 0x4, 0x12, 0x1b, 0x36, 0x27, 0x13, 0x6, 0x0, 0x16, 0x10, 0xa, 0x23, 0x2b, 0x1, 0x17, 0x1c, 0x24, 0x11, 0x7, 0x35, 0x22, 0x2d, 0xc, 0x19, 0x2f, 0x26, 0xb, 0x37, 0xd, 0x2e, 0x1a, 0x2a, 0x3, 0xe, 0xf, 0x9, 0x25, 0x15, 0x18, 0x2c, 0x8, 0x32, 0x1d, 0x1b, 0x6, 0x37, 0x27, 0x28, 0xb, 0x19, 0x22, 0x4, 0x2e, 0x1a, 0xd, 0x7, 0x1d, 0x17, 0x11, 0x2a, 0x32, 0x8, 0x1e, 0x23, 0x2b, 0x18, 0xe, 0x1f, 0x29, 0x34, 0x13, 0x20, 0x36, 0x2d, 0x12, 0x5, 0x14, 0x35, 0x21, 0x31, 0xa, 0x15, 0x16, 0x10, 0x2c, 0x1c, 0x0, 0x33, 0xf, 0x2, 0x24)
|
||||
b = byteArrayOf(0x1f, 0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0xf, 0xe, 0xd, 0xc, 0xb, 0xa, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0x1b, 0x1a, 0x19, 0x18, 0x17, 0x16, 0x13, 0x12, 0x11, 0x10, 0xf, 0xe, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x3, 0x2, 0x1, 0x0, 0x1f, 0x1e)
|
||||
c = intArrayOf(0x2080008, 0x2082000, 0x2008, 0x0, 0x2002000, 0x80008, 0x2080000, 0x2082008, 0x8, 0x2000000, 0x82000, 0x2008, 0x82008, 0x2002008, 0x2000008, 0x2080000, 0x2000, 0x82008, 0x80008, 0x2002000, 0x2082008, 0x2000008, 0x0, 0x82000, 0x2000000, 0x80000, 0x2002008, 0x2080008, 0x80000, 0x2000, 0x2082000, 0x8, 0x80000, 0x2000, 0x2000008, 0x2082008, 0x2008, 0x2000000, 0x0, 0x82000, 0x2080008, 0x2002008, 0x2002000, 0x80008, 0x2082000, 0x8, 0x80008, 0x2002000, 0x2082008, 0x80000, 0x2080000, 0x2000008, 0x82000, 0x2008, 0x2002008, 0x2080000, 0x8, 0x2082000, 0x82008, 0x0, 0x2000000, 0x2080008, 0x2000, 0x82008)
|
||||
d = intArrayOf(0x8000004, 0x20004, 0x0, 0x8020200, 0x20004, 0x200, 0x8000204, 0x20000, 0x204, 0x8020204, 0x20200, 0x8000000, 0x8000200, 0x8000004, 0x8020000, 0x20204, 0x20000, 0x8000204, 0x8020004, 0x0, 0x200, 0x4, 0x8020200, 0x8020004, 0x8020204, 0x8020000, 0x8000000, 0x204, 0x4, 0x20200, 0x20204, 0x8000200, 0x204, 0x8000000, 0x8000200, 0x20204, 0x8020200, 0x20004, 0x0, 0x8000200, 0x8000000, 0x200, 0x8020004, 0x20000, 0x20004, 0x8020204, 0x20200, 0x4, 0x8020204, 0x20200, 0x20000, 0x8000204, 0x8000004, 0x8020000, 0x20204, 0x0, 0x200, 0x8000004, 0x8000204, 0x8020200, 0x8020000, 0x204, 0x4, 0x8020004)
|
||||
e = intArrayOf(-0x7ffbff00, 0x1000100, -0x80000000, -0x7efbff00, 0x0, 0x1040000, -0x7effff00, -0x7ffc0000, 0x1040100, -0x7f000000, 0x1000000, -0x7fffff00, -0x7f000000, -0x7ffbff00, 0x40000, 0x1000000, -0x7efc0000, 0x40100, 0x100, -0x80000000, 0x40100, -0x7effff00, 0x1040000, 0x100, -0x7fffff00, -0x0, -0x7ffc0000, 0x1040100, 0x1000100, -0x7efc0000, -0x7efbff00, 0x40000, -0x7efc0000, -0x7fffff00, 0x40000, -0x7f000000, 0x40100, 0x1000100, -0x80000000, 0x1040000, -0x7effff00, -0x0, 0x100, -0x7ffc0000, -0x0, -0x7efc0000, 0x1040100, 0x100, 0x1000000, -0x7efbff00, -0x7ffbff00, 0x40000, -0x7efbff00, -0x80000000, 0x1000100, -0x7ffbff00, -0x7ffc0000, 0x40100, 0x1040000, -0x7effff00, -0x7fffff00, 0x1000000, -0x7f000000, 0x1040100)
|
||||
f = intArrayOf(0x4010801, 0x0, 0x10800, 0x4010000, 0x4000001, 0x801, 0x4000800, 0x10800, 0x800, 0x4010001, 0x1, 0x4000800, 0x10001, 0x4010800, 0x4010000, 0x1, 0x10000, 0x4000801, 0x4010001, 0x800, 0x10801, 0x4000000, 0x0, 0x10001, 0x4000801, 0x10801, 0x4010800, 0x4000001, 0x4000000, 0x10000, 0x801, 0x4010801, 0x10001, 0x4010800, 0x4000800, 0x10801, 0x4010801, 0x10001, 0x4000001, 0x0, 0x4000000, 0x801, 0x10000, 0x4010001, 0x800, 0x4000000, 0x10801, 0x4000801, 0x4010800, 0x800, 0x0, 0x4000001, 0x1, 0x4010801, 0x10800, 0x4010000, 0x4010001, 0x10000, 0x801, 0x4000800, 0x4000801, 0x1, 0x4010000, 0x10800)
|
||||
g = intArrayOf(0x400, 0x20, 0x100020, 0x40100000, 0x40100420, 0x40000400, 0x420, 0x0, 0x100000, 0x40100020, 0x40000020, 0x100400, 0x40000000, 0x100420, 0x100400, 0x40000020, 0x40100020, 0x400, 0x40000400, 0x40100420, 0x0, 0x100020, 0x40100000, 0x420, 0x40100400, 0x40000420, 0x100420, 0x40000000, 0x40000420, 0x40100400, 0x20, 0x100000, 0x40000420, 0x100400, 0x40100400, 0x40000020, 0x400, 0x20, 0x100000, 0x40100400, 0x40100020, 0x40000420, 0x420, 0x0, 0x20, 0x40100000, 0x40000000, 0x100020, 0x0, 0x40100020, 0x100020, 0x420, 0x40000020, 0x400, 0x40100420, 0x100000, 0x100420, 0x40000000, 0x40000400, 0x40100420, 0x40100000, 0x100420, 0x100400, 0x40000400)
|
||||
h = intArrayOf(0x800000, 0x1000, 0x40, 0x801042, 0x801002, 0x800040, 0x1042, 0x801000, 0x1000, 0x2, 0x800002, 0x1040, 0x800042, 0x801002, 0x801040, 0x0, 0x1040, 0x800000, 0x1002, 0x42, 0x800040, 0x1042, 0x0, 0x800002, 0x2, 0x800042, 0x801042, 0x1002, 0x801000, 0x40, 0x42, 0x801040, 0x801040, 0x800042, 0x1002, 0x801000, 0x1000, 0x2, 0x800002, 0x800040, 0x800000, 0x1040, 0x801042, 0x0, 0x1042, 0x800000, 0x40, 0x1002, 0x800042, 0x40, 0x0, 0x801042, 0x801002, 0x801040, 0x42, 0x1000, 0x1040, 0x801002, 0x800040, 0x42, 0x2, 0x1042, 0x801000, 0x800002)
|
||||
i = intArrayOf(0x10400000, 0x404010, 0x10, 0x10400010, 0x10004000, 0x400000, 0x10400010, 0x4010, 0x400010, 0x4000, 0x404000, 0x10000000, 0x10404010, 0x10000010, 0x10000000, 0x10404000, 0x0, 0x10004000, 0x404010, 0x10, 0x10000010, 0x10404010, 0x4000, 0x10400000, 0x10404000, 0x400010, 0x10004010, 0x404000, 0x4010, 0x0, 0x400000, 0x10004010, 0x404010, 0x10, 0x10000000, 0x4000, 0x10000010, 0x10004000, 0x404000, 0x10400010, 0x0, 0x404010, 0x4010, 0x10404000, 0x10004000, 0x400000, 0x10404010, 0x10000000, 0x10004010, 0x10400000, 0x400000, 0x10404010, 0x4000, 0x400010, 0x10400010, 0x4010, 0x400010, 0x0, 0x10404000, 0x10000010, 0x10400000, 0x10004010, 0x10, 0x404000)
|
||||
j = intArrayOf(0x208080, 0x8000, 0x20200000, 0x20208080, 0x200000, 0x20008080, 0x20008000, 0x20200000, 0x20008080, 0x208080, 0x208000, 0x20000080, 0x20200080, 0x200000, 0x0, 0x20008000, 0x8000, 0x20000000, 0x200080, 0x8080, 0x20208080, 0x208000, 0x20000080, 0x200080, 0x20000000, 0x80, 0x8080, 0x20208000, 0x80, 0x20200080, 0x20208000, 0x0, 0x0, 0x20208080, 0x200080, 0x20008000, 0x208080, 0x8000, 0x20000080, 0x200080, 0x20208000, 0x80, 0x8080, 0x20200000, 0x20008080, 0x20000000, 0x20200000, 0x208000, 0x20208080, 0x8080, 0x208000, 0x20200080, 0x200000, 0x20000080, 0x20008000, 0x0, 0x8000, 0x200000, 0x20200080, 0x208080, 0x20000000, 0x20208000, 0x80, 0x20008080)
|
||||
}
|
||||
|
||||
private fun a(arg2: Int, arg3: Int): Int {
|
||||
return arg2 shl 32 - arg3 or arg2.ushr(arg3)
|
||||
}
|
||||
|
||||
private fun a(arg5: ByteArray, arg6: Long) {
|
||||
var v0 = arg6.ushr(32).toInt()
|
||||
var v1 = a(arg6.toInt(), 31)
|
||||
var v2 = v0 xor v1 and 1431655765
|
||||
v1 = v1 xor v2
|
||||
v0 = a(v0 xor v2, 31)
|
||||
v2 = v1.ushr(8) xor v0 and 16711935
|
||||
v1 = v1 xor (v2 shl 8)
|
||||
v0 = v0 xor v2
|
||||
v2 = v0.ushr(2) xor v1 and 858993459
|
||||
v0 = v0 xor (v2 shl 2)
|
||||
v1 = v1 xor v2
|
||||
v2 = v1.ushr(16) xor v0 and 65535
|
||||
v1 = v1 xor (v2 shl 16)
|
||||
v0 = v0 xor v2
|
||||
v2 = v0.ushr(4) xor v1 and 252645135
|
||||
v0 = v0 xor (v2 shl 4)
|
||||
v1 = v1 xor v2
|
||||
arg5[0] = v1.toByte()
|
||||
arg5[1] = v1.ushr(8).toByte()
|
||||
arg5[2] = v1.ushr(16).toByte()
|
||||
arg5[3] = (v1 shr 24).toByte()
|
||||
arg5[4] = v0.toByte()
|
||||
arg5[5] = v0.ushr(8).toByte()
|
||||
arg5[6] = v0.ushr(16).toByte()
|
||||
arg5[7] = (v0 shr 24).toByte()
|
||||
}
|
||||
|
||||
private fun c(arg6: ByteArray): Long {
|
||||
var v0 = arg6[0].toInt() and 255 or (arg6[1].toInt() and 255 shl 8) or (arg6[2].toInt() and 255 shl 16) or (arg6[3].toInt() and 255 shl 24)
|
||||
var v1 = arg6[4].toInt() and 255 or (arg6[5].toInt() and 255 shl 8) or (arg6[6].toInt() and 255 shl 16) or (arg6[7].toInt() and 255 shl 24)
|
||||
var v2 = v1.ushr(4) xor v0 and 252645135 shl 4 xor v1
|
||||
v0 = v0 xor (v1.ushr(4) xor v0 and 252645135)
|
||||
v1 = v0.ushr(16) xor v2 and 65535
|
||||
v0 = v0 xor (v0.ushr(16) xor v2 shl 16)
|
||||
v1 = v1 xor v2
|
||||
v2 = v1.ushr(2) xor v0 and 858993459
|
||||
v1 = v1 xor (v2 shl 2)
|
||||
v0 = v0 xor v2
|
||||
v2 = v0.ushr(8) xor v1 and 16711935
|
||||
v0 = v0 xor (v2 shl 8)
|
||||
v1 = a(v1 xor v2, 1)
|
||||
v2 = v0 xor v1 and 1431655765
|
||||
return (v1 xor v2).toLong() and 4294967295L or (a(v0 xor v2, 1).toLong() shl 32)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
52
android/app/src/main/java/tk/nulldori/eamemu/E.kt
Normal file
52
android/app/src/main/java/tk/nulldori/eamemu/E.kt
Normal file
@ -0,0 +1,52 @@
|
||||
package tk.nulldori.eamemu
|
||||
|
||||
object E {
|
||||
fun a(arg4: CharSequence): ByteArray {
|
||||
if (arg4.length % 2 != 0) {
|
||||
//throw new d("Trailing nibble detected");
|
||||
}
|
||||
|
||||
val v1 = ByteArray(arg4.length / 2)
|
||||
var v0: Int
|
||||
v0 = 0
|
||||
while (v0 < v1.size) {
|
||||
v1[v0] = (E.a(arg4[v0 * 2]).toInt() shl 4 or E.a(arg4[v0 * 2 + 1]).toInt()).toByte()
|
||||
++v0
|
||||
}
|
||||
|
||||
return v1
|
||||
}
|
||||
|
||||
fun a(arg5: ByteArray): String {
|
||||
val v1 = "0123456789ABCDEF"
|
||||
val v2 = CharArray(arg5.size shl 1)
|
||||
var v0: Int
|
||||
v0 = 0
|
||||
while (v0 < arg5.size) {
|
||||
v2[v0 * 2] = v1[(arg5[v0].toInt() and 255).ushr(4)]
|
||||
v2[v0 * 2 + 1] = v1[arg5[v0].toInt() and 15]
|
||||
++v0
|
||||
}
|
||||
|
||||
return String(v2)
|
||||
}
|
||||
|
||||
private fun a(arg3: Char): Byte {
|
||||
val v0: Byte
|
||||
if (arg3.toInt() < 48 || arg3.toInt() > 57) {
|
||||
if (arg3.toInt() >= 65 && arg3.toInt() <= 70) {
|
||||
return (arg3.toInt() - 55).toByte()
|
||||
}
|
||||
|
||||
return if (arg3.toInt() >= 97 && arg3.toInt() <= 102) {
|
||||
(arg3.toInt() - 87).toByte()
|
||||
} else 0x00
|
||||
|
||||
} else {
|
||||
v0 = (arg3.toInt() - 48).toByte()
|
||||
}
|
||||
|
||||
return v0
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +0,0 @@
|
||||
import {NativeModules} from 'react-native';
|
||||
|
||||
module.exports = NativeModules.CardConv;
|
9
src/module/CardConv.ts
Normal file
9
src/module/CardConv.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { NativeModules } from 'react-native';
|
||||
|
||||
const { CardConv } = NativeModules;
|
||||
|
||||
interface CardConvModule {
|
||||
convertSID: (sid: string) => Promise<string>;
|
||||
}
|
||||
|
||||
export default CardConv as CardConvModule;
|
Loading…
Reference in New Issue
Block a user