@Override
    public JSONObject toJson() {
        JSONObject obj = super.toJson();
        try {
            obj.put("counter", getCounter());
        } catch (JSONException e) {
            throw new RuntimeException(e);
        }
        return obj;
    }
@Test
    public void testHotpMd5Override() throws OtpInfoException {
        final byte[] secret = new byte[]{1, 2, 3, 4};
        MotpInfo motpInfo = new MotpInfo(secret, "1234");
        motpInfo = (MotpInfo) OtpInfo.fromJson("motp", motpInfo.toJson());
        assertEquals("MD5", motpInfo.getAlgorithm(false));

        HotpInfo info = new HotpInfo(secret);
        info.setAlgorithm("MD5");
        info = (HotpInfo) OtpInfo.fromJson("hotp", info.toJson());
        assertEquals(OtpInfo.DEFAULT_ALGORITHM, info.getAlgorithm(false));

        info.setAlgorithm("SHA256");
        info = (HotpInfo) OtpInfo.fromJson("hotp", info.toJson());
        assertEquals("SHA256", info.getAlgorithm(false));
    }