Strip Padding From Karn-Encrypted Strings

The Karn string you are trying to decrypt contains only non-zero characters. But the padding was added right after a real zero. Hence to strip padding you can use this code:

   // Strip the padding off the byte array and return the string 
   private String StripPadding (byte input[]) {
      ByteArrayOutputStream buffer = new ByteArrayOutputStream();
      for (int i=0 ; i < input.length && input[i] != 0 ; i++) 
         buffer.write(input[i]);
      return (new String(buffer.toByteArray()));
   }