@Test public void pinWithWhitespaces() { // Let's shoot some holes into the pin string final int[] subsequences = new int[] { 4, 17, 21, 32 }; StringBuilder sb = new StringBuilder(); int start = 0; for (int i : subsequences) { sb.append(PIN_STRING_W_COLON.subSequence(start, i)); sb.append(' '); start = i; } sb.append(PIN_STRING_W_COLON.subSequence(start, PIN_STRING_W_COLON.length())); Pin pin = Pin.fromString("CERTSHA256:" + sb.toString()); byte[] pinBytes = pin.getPinBytes(); final String pinString = HexUtilities.encodeToHex(pinBytes, true, true); // String.format() appends a ':' at the very end, so we have to do that too assertEquals(PIN_STRING_W_COLON, pinString); }
@Test public void pinWithFullwidthColon() { Pin pin = Pin.fromString("CERTSHA256:" + PIN_STRING_W_COLON); byte[] pinBytes = pin.getPinBytes(); final String pinString = HexUtilities.encodeToHex(pinBytes, true, true); // String.format() appends a ':' at the very end, so we have to do that too assertEquals(PIN_STRING_W_COLON, pinString); }