Examples of Hash


Examples of com.hp.hpl.jena.tdb.store.Hash

        return nodeId ;
    }
   
    protected final NodeId accessIndex(Node node, boolean create)
    {
        Hash hash = new Hash(nodeHashToId.getRecordFactory().keyLength()) ;
        setHash(hash, node) ;
        byte k[] = hash.getBytes() ;       
        // Key only.
        Record r = nodeHashToId.getRecordFactory().create(k) ;
       
        synchronized (this// Pair to readNodeFromTable.
        {
View Full Code Here

Examples of com.hp.hpl.jena.tdb.store.Hash

                long x = Long.parseLong(id) ;
                NodeId nodeId = new NodeId(x) ;
                Node n = nodeTable.getNodeForNodeId(nodeId) ;
                //System.out.printf("%s [%d] => %s\n", id, x, n) ;

                Hash h = new Hash(SystemTDB.LenNodeHash) ;
                NodeLib.setHash(h, n) ;
                String str = Bytes.asHex(h.getBytes()) ;
                System.out.printf("%s %08d 0x%s # %s\n", id, x, str, n) ;
            } catch (Exception ex)
            {
                System.out.println("Failed to decode: "+id) ;
            }
View Full Code Here

Examples of com.maverick.crypto.digests.Hash

        if (qopVariant == QOP_AUTH_INT) {
            throw new IOException(Messages.getString("DigestAuthentication.unsupportedQop")); //$NON-NLS-1$
        }

        Hash hash = new Hash(new MD5Digest());

        // 3.2.2.2: Calculating digest
        StringBuffer tmp = new StringBuffer(uname.length() + realm.length() + pwd.length() + 2);
        tmp.append(uname);
        tmp.append(':');
        tmp.append(realm);
        tmp.append(':');
        tmp.append(pwd);
        // unq(username-value) ":" unq(realm-value) ":" passwd
        String a1 = tmp.toString();
        // a1 is suitable for MD5 algorithm
        if (algorithm.equals("MD5-sess")) { //$NON-NLS-1$
            // H( unq(username-value) ":" unq(realm-value) ":" passwd )
            // ":" unq(nonce-value)
            // ":" unq(cnonce-value)

            hash.putBytes(a1.getBytes("US-ASCII")); //$NON-NLS-1$
            String tmp2 = encode(hash.doFinal());
            StringBuffer tmp3 = new StringBuffer(tmp2.length() + nonce.length() + cnonce.length() + 2);
            tmp3.append(tmp2);
            tmp3.append(':');
            tmp3.append(nonce);
            tmp3.append(':');
            tmp3.append(cnonce);
            a1 = tmp3.toString();
        } else if (!algorithm.equals("MD5")) { //$NON-NLS-1$

        }

        hash.reset();
        hash.putBytes(a1.getBytes("US-ASCII")); //$NON-NLS-1$
        String md5a1 = encode(hash.doFinal());

        String a2 = null;
        if (qopVariant == QOP_AUTH_INT) {
            // we do not have access to the entity-body or its hash
            // TODO: add Method ":" digest-uri-value ":" H(entity-body)
        } else {
            a2 = method + ":" + uri; //$NON-NLS-1$
        }

        hash.reset();
        hash.putBytes(a2.getBytes("US-ASCII")); //$NON-NLS-1$
        String md5a2 = encode(hash.doFinal());

        // 3.2.2.1
        String serverDigestValue;
        if (qopVariant == QOP_MISSING) {

            StringBuffer tmp2 = new StringBuffer(md5a1.length() + nonce.length() + md5a2.length());
            tmp2.append(md5a1);
            tmp2.append(':');
            tmp2.append(nonce);
            tmp2.append(':');
            tmp2.append(md5a2);
            serverDigestValue = tmp2.toString();
        } else {

            String qopOption = getQopVariantString();
            StringBuffer tmp2 = new StringBuffer(md5a1.length() + nonce.length() + NC.length() + cnonce.length()
                + qopOption.length() + md5a2.length() + 5);
            tmp2.append(md5a1);
            tmp2.append(':');
            tmp2.append(nonce);
            tmp2.append(':');
            tmp2.append(NC);
            tmp2.append(':');
            tmp2.append(cnonce);
            tmp2.append(':');
            tmp2.append(qopOption);
            tmp2.append(':');
            tmp2.append(md5a2);
            serverDigestValue = tmp2.toString();
        }

        hash.reset();
        hash.putBytes(serverDigestValue.getBytes("US-ASCII")); //$NON-NLS-1$
        String serverDigest = encode(hash.doFinal());

        return serverDigest;
    }
View Full Code Here

Examples of com.maverick.crypto.digests.Hash

    }

    public static String createCnonce() {

        String cnonce;
        Hash hash = new Hash(new MD5Digest());

        cnonce = Long.toString(System.currentTimeMillis());

        hash.putBytes(cnonce.getBytes());
        cnonce = encode(hash.doFinal());

        return cnonce;
    }
View Full Code Here

Examples of com.maverick.crypto.digests.Hash

        return true;
    }

    private byte[] makePassphraseKey(String passphrase) {
            // Generate the key using the passphrase
            Hash md5 = new Hash("MD5");
            md5.putBytes(passphrase.getBytes());

            byte[] key1 = md5.doFinal();
            md5.reset();
            md5.putBytes(passphrase.getBytes());
            md5.putBytes(key1);

            byte[] key2 = md5.doFinal();
            byte[] key = new byte[32];
            System.arraycopy(key1, 0, key, 0, 16);
            System.arraycopy(key2, 0, key, 16, 16);

            return key;
View Full Code Here

Examples of com.maverick.crypto.digests.Hash

     *
     *
     * @return
     */
    public String getFingerprint() {
            Hash md5 = new Hash("MD5");
            md5.putBytes(getEncoded());

            byte[] digest = md5.doFinal();
            int bits = getBitLength();
            bits = (((bits % 8) != 0) ? (bits += (bits % 8)) : bits);

            String ret = String.valueOf(bits);

View Full Code Here

Examples of com.maverick.crypto.digests.Hash

        lastAccessTime = System.currentTimeMillis();

        /**
         * Generate a unique session id
         */
        Hash hash = new Hash(new MD5Digest());
        hash.putString(String.valueOf(logonTime));
        if(session != null) {
            hash.putString(session.getId());
        }
        hash.putInt(id);
        hash.putString(user.getPrincipalName());
        hash.putString(address.getHostAddress());
        byte[] tmp = hash.doFinal();
        uid = Util.toHexString(tmp);
       
        CoreServlet.getServlet().addCoreListener(this);
    }
View Full Code Here

Examples of com.sshtools.j2ssh.util.Hash

    }

    private byte[] makePassphraseKey(String passphrase) {
        try {
            // Generate the key using the passphrase
            Hash md5 = new Hash("MD5");
            md5.putBytes(passphrase.getBytes());

            byte[] key1 = md5.doFinal();
            md5.reset();
            md5.putBytes(passphrase.getBytes());
            md5.putBytes(key1);

            byte[] key2 = md5.doFinal();
            byte[] key = new byte[32];
            System.arraycopy(key1, 0, key, 0, 16);
            System.arraycopy(key2, 0, key, 16, 16);

            return key;
View Full Code Here

Examples of com.sshtools.j2ssh.util.Hash

     *
     * @return
     */
    public String getFingerprint() {
        try {
            Hash md5 = new Hash("MD5");
            md5.putBytes(getEncoded());

            byte[] digest = md5.doFinal();
            int bits = getBitLength();
            bits = (((bits % 8) != 0) ? (bits += (bits % 8)) : bits);

            String ret = String.valueOf(bits);

View Full Code Here

Examples of com.torrent4j.util.Hash

        ((PeerWireFrameDecoder) e.getChannel().getPipeline()
            .get("frame-decoder")).setHandshaked(true);
        ((PeerWireMessageDecoder) e.getChannel().getPipeline()
            .get("message-decoder")).setHandshaked(true);

        final Hash hash = new Hash(HashType.SHA1, message.torrentHash);
        final Torrent torrent = controller.findTorrent(hash);

        if (torrent == null) {
          e.getChannel().disconnect();
          return;
        }

        TorrentPeer peer = torrent.getSwarm().findPeer(
            (InetSocketAddress) e.getChannel().getRemoteAddress(),
            message.peerID);
        if (peer == null) {
          peer = new TorrentPeer(torrent);
          peer.setAddress((InetSocketAddress) e.getChannel()
              .getRemoteAddress());
        }
        peer.setPeerID(message.peerID);
       
        this.peer = (PeerWireProtocolPeer) peer.getProtocolPeer();

        e.getChannel().getPipeline()
            .get(PeerTrafficShapingHandler.class).setPeer(peer);
        e.getChannel().getPipeline()
            .get(TorrentTrafficShapingHandler.class)
            .setTorrent(torrent);

        peer.resetState();
        this.peer.getStrategy().getPeerStrategy()
            .peerConnected(torrent, peer);
      } else if (msg instanceof HaveMessage) {
        peer.getTorrentPeer()
            .getPieces()
            .addPiece(
                peer.getTorrent().getPiece(
                    ((HaveMessage) msg).pieceIndex));
        peer.getStrategy()
            .getPeerStrategy()
            .havePiece(
                peer.getTorrent(),
                peer.getTorrentPeer(),
                peer.getTorrent().getPiece(
                    ((HaveMessage) msg).pieceIndex));
      } else if (msg instanceof UnchokeMessage) {
        peer.getTorrentPeer().getState()
            .setRemoteChoked(TorrentPeerChoking.UNCHOKED);
        peer.getStrategy().getPeerStrategy()
            .unchoked(peer.getTorrent(), peer.getTorrentPeer());
      } else if (msg instanceof ChokeMessage) {
        peer.getTorrentPeer().getState()
            .setRemoteChoked(TorrentPeerChoking.CHOKED);
        peer.getStrategy().getPeerStrategy()
            .choked(peer.getTorrent(), peer.getTorrentPeer());
      } else if (msg instanceof InterestedMessage) {
        peer.getTorrentPeer().getState()
            .setRemoteInterest(TorrentPeerInterest.INTERESTED);
        peer.getStrategy().getPeerStrategy()
            .interested(peer.getTorrent(), peer.getTorrentPeer());
      } else if (msg instanceof NotInterestedMessage) {
        peer.getTorrentPeer().getState()
            .setRemoteInterest(TorrentPeerInterest.NOT_INTERESTED);
        peer.getStrategy()
            .getPeerStrategy()
            .notInterested(peer.getTorrent(), peer.getTorrentPeer());
      } else if (msg instanceof BitFieldMessage) {
        peer.getTorrentPeer().getPieces()
            .load(((BitFieldMessage) msg).bitSet);
        peer.getStrategy().getPeerStrategy()
            .bitField(peer.getTorrent(), peer.getTorrentPeer());
      } else if (msg instanceof RequestMessage) {
        final RequestMessage message = (RequestMessage) msg;

        final TorrentPiece piece = peer.getTorrent().getPiece(
            message.pieceIndex);
        final TorrentPieceBlock block = piece.getBlock(message.begin,
            message.length);
       
        if(peer.getTorrentPeer().getState().hasUploadRequestedBlock()) {
          peer.disconnect();
          return;
        }

        peer.getTorrentPeer().getState().setUploadRequestedBlock(block);
        peer.getTorrentPeer().getState()
            .setUploadRequestedDate(new Date());

        peer.getStrategy()
            .getUploadStrategy()
            .blockRequested(peer.getTorrent(), block,
                peer.getTorrentPeer());
      } else if (msg instanceof CancelMessage) {
        final CancelMessage message = (CancelMessage) msg;

        final TorrentPiece piece = peer.getTorrent().getPiece(
            message.pieceIndex);
        final TorrentPieceBlock block = piece.getBlock(message.begin,
            message.length);

        peer.getTorrentPeer().getState().setUploadRequestedBlock(null);
        peer.getTorrentPeer().getState().setUploadRequestedDate(null);

        peer.getStrategy()
            .getUploadStrategy()
            .blockRequestCancelled(peer.getTorrent(), block,
                peer.getTorrentPeer());
      } else if (msg instanceof BlockMessage) {
        final BlockMessage message = (BlockMessage) msg;

        final TorrentPiece piece = peer.getTorrent().getPiece(
            message.pieceIndex);
        final TorrentPieceBlock block = piece.getBlock(message.begin,
            message.data.remaining());

        peer.getTorrentPeer().getState().setLastDownloadedBlock(block);
        peer.getTorrentPeer().getState()
            .setLastDownloadedBlockDate(new Date());

        peer.getTorrentPeer().getState()
            .setDownloadRequestedBlock(null);
        peer.getTorrentPeer().getState().setDownloadRequestedDate(null);

        controller.getStorage().write(piece.getTorrent(),
            block.getTorrentRange(), message.data);
        block.setDownloaded(true);
        if (piece.isDownloaded()) {
          final Hash pieceHash = controller.getStorage().checksum(
              piece);
          if (!piece.getHash().equals(pieceHash)) {
            piece.getTorrent()
                .getStrategy()
                .getDownloadStrategy()
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.