freemail.HashSlotManager.java Source code

Java tutorial

Introduction

Here is the source code for freemail.HashSlotManager.java

Source

/*
 * HashSlotManager.java
 * This file is part of Freemail, copyright (C) 2006 Dave Baker
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

package freemail;

import org.archive.util.Base32;

import org.bouncycastle.crypto.digests.SHA256Digest;

public class HashSlotManager extends SlotManager {
    HashSlotManager(SlotSaveCallback cb, Object userdata, String slotlist) {
        super(cb, userdata, slotlist);
    }

    @Override
    protected String incSlot(String slot) {
        byte[] buf = Base32.decode(slot);
        SHA256Digest sha256 = new SHA256Digest();
        sha256.update(buf, 0, buf.length);
        sha256.doFinal(buf, 0);

        return Base32.encode(buf);
    }
}