Created
May 21, 2018 12:56
-
-
Save Tolsi/3b63990daaab63c13780db91f3309f89 to your computer and use it in GitHub Desktop.
Scala base58 bytes array size by string and string length by bytes array size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Base58Length { | |
private val BytesMaxValue = 256 | |
private val Base58MaxValue = 58 | |
private val BytesLog = math.log(BytesMaxValue) | |
private val BaseLog = math.log(Base58MaxValue) | |
def base58Length(byteArrayLength: Int): Int = math.ceil(BytesLog / BaseLog * byteArrayLength).toInt | |
def bytesLength(base58Length: Int): Int = math.ceil(BaseLog / BytesLog * base58Length).toInt | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment