[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-kotlin] 02/03: Fix Base32Crockford decoding
From: |
gnunet |
Subject: |
[taler-wallet-kotlin] 02/03: Fix Base32Crockford decoding |
Date: |
Wed, 03 Jun 2020 14:09:49 +0200 |
This is an automated email from the git hooks/post-receive script.
torsten-grote pushed a commit to branch master
in repository wallet-kotlin.
commit 75667b9fd2644b737aee17c5c43f1c0f260f7c0d
Author: Torsten Grote <t@grobox.de>
AuthorDate: Mon Jun 1 16:13:24 2020 -0300
Fix Base32Crockford decoding
and add decoder test for FUCK (which still fails)
---
.../kotlin/net/taler/wallet/kotlin/Base32Crockford.kt | 2 +-
.../kotlin/net/taler/wallet/kotlin/Base32CrockfordTest.kt | 13 +++++++++++--
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/commonMain/kotlin/net/taler/wallet/kotlin/Base32Crockford.kt
b/src/commonMain/kotlin/net/taler/wallet/kotlin/Base32Crockford.kt
index ac49dc6..c966af2 100644
--- a/src/commonMain/kotlin/net/taler/wallet/kotlin/Base32Crockford.kt
+++ b/src/commonMain/kotlin/net/taler/wallet/kotlin/Base32Crockford.kt
@@ -76,7 +76,7 @@ object Base32Crockford {
if (a in '0'..'9')
return a - '0'
if (a in 'a'..'z')
- a.toUpperCase()
+ a = a.toUpperCase()
var dec = 0
if (a in 'A'..'Z') {
if ('I' < a) dec++
diff --git
a/src/commonTest/kotlin/net/taler/wallet/kotlin/Base32CrockfordTest.kt
b/src/commonTest/kotlin/net/taler/wallet/kotlin/Base32CrockfordTest.kt
index c5940e6..daa505a 100644
--- a/src/commonTest/kotlin/net/taler/wallet/kotlin/Base32CrockfordTest.kt
+++ b/src/commonTest/kotlin/net/taler/wallet/kotlin/Base32CrockfordTest.kt
@@ -1,5 +1,6 @@
package net.taler.wallet.kotlin
+import kotlin.test.Ignore
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
@@ -79,10 +80,18 @@ class Base32CrockfordTest {
for (vector in vectors) {
for (encoding in vector.encoding) {
assertTrue(vector.value contentEquals
Base32Crockford.decode(encoding))
- // TODO current implementation is throwing [EncodingException]
for alternative encodings
- break
}
}
}
+ @Ignore // TODO
+ @Test
+ fun testDecodeFuck() {
+ val bytes = byteArrayOf(0x7e, 0xd9.toByte())
+ assertTrue(bytes contentEquals Base32Crockford.decode("FUCK"))
+ assertTrue(bytes contentEquals Base32Crockford.decode("FuCk"))
+ assertTrue(bytes contentEquals Base32Crockford.decode("fUcK"))
+ assertTrue(bytes contentEquals Base32Crockford.decode("FVCK"))
+ }
+
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.