public Checksum(MessageDigest digest) { this(ChecksumType.getChecksumType(digest.getAlgorithm()), digest.digest()); }
/** * * @param inode */ List<Checksum> getInodeChecksums(FsInode inode) { return _jdbc.query("SELECT isum, itype FROM t_inodes_checksum WHERE inumber=?", ps -> ps.setLong(1, inode.ino()), (rs, rowNum) -> { String checksum = rs.getString("isum"); int type = rs.getInt("itype"); return new Checksum(ChecksumType.getChecksumType(type), checksum); }); }
/** * Create a new checksum instance for an already computed digest * of a particular type. * * @param digest the input must have the following format: * <type>:<hexadecimal digest> * @throws IllegalArgumentException if argument has wrong form * @throws NullPointerException if argument is null */ public static Checksum parseChecksum(String digest) { checkNotNull(digest, "value may not be null"); int del = digest.indexOf(DELIMITER); if (del < 1) { throw new IllegalArgumentException("Not a dCache checksum: " + digest); } String type = digest.substring(0, del); String checksum = digest.substring(del + 1); return new Checksum(ChecksumType.getChecksumType(type), checksum); } }