public static byte[] decodeChecked(String input) throws AddressFormatException {
  byte tmp[]=decode(input);
  if (tmp.length < 4)   throw new AddressFormatException("Input too short");
  byte[] bytes=copyOfRange(tmp,0,tmp.length - 4);
  byte[] checksum=copyOfRange(tmp,tmp.length - 4,tmp.length);
  tmp=Utils.doubleDigest(bytes);
  byte[] hash=copyOfRange(tmp,0,4);
  if (!Arrays.equals(checksum,hash))   throw new AddressFormatException("Checksum does not validate");
  return bytes;
}

public static byte [ ] decodeChecked ( String input ) throws AddressFormatException { byte tmp [ ] = decode ( input ) ; if ( tmp . length < 4 ) throw new AddressFormatException ( "Input too short" ) ; byte [ ] bytes = copyOfRange ( tmp , 0 , tmp . length - 4 ) ; byte [ ] checksum = copyOfRange ( tmp , tmp . length - 4 , tmp . length ) ; tmp = Utils . doubleDigest ( bytes ) ; byte [ ] hash = copyOfRange ( tmp , 0 , 4 ) ; if ( ! Arrays . equals ( checksum , hash ) ) throw new AddressFormatException ( "Checksum does not validate" ) ; return bytes ; }
uses the checksum in the last 4 bytes of the decoded data to verify the rest are correct . the checksum is removed from the returned data .
