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

commonMain.com.inkapplications.ack.client.Passcodes.kt Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
package com.inkapplications.ack.client

fun generatePasscode(address: String): Int {
    var hash = 0x73e2
    address
        .substringBefore('-')
        .uppercase()
        .toCharArray()
        .forEachIndexed { index, c ->
            if (index % 2 == 0) {
                hash = hash.xor(c.code.shl(8))
            } else {
                hash = hash.xor(c.code)
            }
        }

    return hash.and(0x7fff)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy