Java Code Examples for org.apache.commons.codec.digest.DigestUtils#md5()
The following examples show how to use
org.apache.commons.codec.digest.DigestUtils#md5() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BasicTranslator.java From zerowing with MIT License | 6 votes |
@Override public byte[] createRowKey(BSONObject object) { Object id = object.get("_id"); byte[] raw; if (id instanceof ObjectId) { raw = ((ObjectId) id).toByteArray(); } else if (id instanceof String) { raw = ((String) id).getBytes(); } else if (id instanceof BSONObject) { raw = bsonEncoder.encode(((BSONObject) id)); } else { throw new RuntimeException("Don't know how to serialize _id: " + id.toString()); } return DigestUtils.md5(raw); }
Example 2
Source File: EncryptDecrypt.java From sample-timesheets with Apache License 2.0 | 5 votes |
public EncryptDecrypt(String key) { try { String data = new StringBuilder(SALT + key).reverse().toString(); SecretKeySpec secretKey = new SecretKeySpec(DigestUtils.md5(data), "AES"); AlgorithmParameterSpec paramSpec = new IvParameterSpec(INIT_VECTOR); eCipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); dCipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); eCipher.init(Cipher.ENCRYPT_MODE, secretKey, paramSpec); dCipher.init(Cipher.DECRYPT_MODE, secretKey, paramSpec); } catch (Exception e) { throw new RuntimeException("Exception while init cipher:", e); } }
Example 3
Source File: AbstractVertex.java From SPADE with GNU General Public License v3.0 | 5 votes |
/** * Computes MD5 hash of annotations in the vertex * @return 16 element byte array of the digest. */ public final byte[] bigHashCodeBytes(){ if(bigHashCode == null){ return DigestUtils.md5(annotations.toString()); // calculated at runtime }else{ return bigHashCode.getBytes(); } }
Example 4
Source File: BuildCause.java From DotCi with MIT License | 5 votes |
@Exported public String getAvatarUrl() { if (this.avatarUrl == null) { if (this.committerEmail == null) return null; final byte[] md5 = DigestUtils.md5(this.committerEmail); final String emailDigest = new BigInteger(1, md5).toString(16); return "https://secure.gravatar.com/avatar/" + emailDigest + ".png?"; } return this.avatarUrl; }
Example 5
Source File: ConvertToHFilesMapper.java From examples with Apache License 2.0 | 5 votes |
@Override protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { // tag::MAP[] // Extract the different fields from the received line. String[] line = value.toString().split(","); // <1> event.setId(line[0]); event.setEventId(line[1]); event.setDocType(line[2]); event.setPartName(line[3]); event.setPartNumber(line[4]); event.setVersion(Long.parseLong(line[5])); event.setPayload(line[6]); // <2> // Serialize the AVRO object into a ByteArray out.reset(); // <3> writer.write(event, encoder); // <4> encoder.flush(); byte[] rowKeyBytes = DigestUtils.md5(line[0]); rowKey.set(rowKeyBytes); // <5> context.getCounter("Convert", line[2]).increment(1); KeyValue kv = new KeyValue(rowKeyBytes, CF, Bytes.toBytes(line[1]), out.toByteArray()); // <6> context.write (rowKey, kv); // <7> // end::MAP[] }
Example 6
Source File: TestBulkImport.java From zerowing with MIT License | 5 votes |
private int[] getValues(HTable table, String id) throws Exception { BSONDecoder decoder = new BasicBSONDecoder(); byte[] raw = DigestUtils.md5(id.getBytes()); Get get = new Get(raw); get.setMaxVersions(); List<KeyValue> kvs = table.get(get).getColumn("z".getBytes(), "w".getBytes()); int[] values = new int[kvs.size()]; for (int i = 0; i < kvs.size(); i++) { values[i] = (Integer) decoder.readObject(kvs.get(i).getValue()).get("num"); } return values; }
Example 7
Source File: HashCrypto.java From openzaly with Apache License 2.0 | 4 votes |
public static byte[] MD5Bytes(String key) { return DigestUtils.md5(key); }
Example 8
Source File: HSSFWorkbook.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Adds a picture to the workbook. * * @param pictureData The bytes of the picture * @param format The format of the picture. One of <code>PICTURE_TYPE_*</code> * * @return the index to this picture (1 based). * @see #PICTURE_TYPE_WMF * @see #PICTURE_TYPE_EMF * @see #PICTURE_TYPE_PICT * @see #PICTURE_TYPE_PNG * @see #PICTURE_TYPE_JPEG * @see #PICTURE_TYPE_DIB */ @SuppressWarnings("fallthrough") @Override public int addPicture(byte[] pictureData, int format) { initDrawings(); byte[] uid = DigestUtils.md5(pictureData); EscherBlipRecord blipRecord; int blipSize; short escherTag; switch (format) { case PICTURE_TYPE_WMF: // remove first 22 bytes if file starts with magic bytes D7-CD-C6-9A // see also http://de.wikipedia.org/wiki/Windows_Metafile#Hinweise_zur_WMF-Spezifikation if (LittleEndian.getInt(pictureData) == 0x9AC6CDD7) { byte picDataNoHeader[] = new byte[pictureData.length-22]; System.arraycopy(pictureData, 22, picDataNoHeader, 0, pictureData.length-22); pictureData = picDataNoHeader; } // fall through case PICTURE_TYPE_EMF: EscherMetafileBlip blipRecordMeta = new EscherMetafileBlip(); blipRecord = blipRecordMeta; blipRecordMeta.setUID(uid); blipRecordMeta.setPictureData(pictureData); // taken from libre office export, it won't open, if this is left to 0 blipRecordMeta.setFilter((byte)-2); blipSize = blipRecordMeta.getCompressedSize() + 58; escherTag = 0; break; default: EscherBitmapBlip blipRecordBitmap = new EscherBitmapBlip(); blipRecord = blipRecordBitmap; blipRecordBitmap.setUID( uid ); blipRecordBitmap.setMarker( (byte) 0xFF ); blipRecordBitmap.setPictureData( pictureData ); blipSize = pictureData.length + 25; escherTag = (short) 0xFF; break; } blipRecord.setRecordId((short) (EscherBlipRecord.RECORD_ID_START + format)); switch (format) { case PICTURE_TYPE_EMF: blipRecord.setOptions(HSSFPictureData.MSOBI_EMF); break; case PICTURE_TYPE_WMF: blipRecord.setOptions(HSSFPictureData.MSOBI_WMF); break; case PICTURE_TYPE_PICT: blipRecord.setOptions(HSSFPictureData.MSOBI_PICT); break; case PICTURE_TYPE_PNG: blipRecord.setOptions(HSSFPictureData.MSOBI_PNG); break; case PICTURE_TYPE_JPEG: blipRecord.setOptions(HSSFPictureData.MSOBI_JPEG); break; case PICTURE_TYPE_DIB: blipRecord.setOptions(HSSFPictureData.MSOBI_DIB); break; default: throw new IllegalStateException("Unexpected picture format: " + format); } EscherBSERecord r = new EscherBSERecord(); r.setRecordId( EscherBSERecord.RECORD_ID ); r.setOptions( (short) ( 0x0002 | ( format << 4 ) ) ); r.setBlipTypeMacOS( (byte) format ); r.setBlipTypeWin32( (byte) format ); r.setUid( uid ); r.setTag( escherTag ); r.setSize( blipSize ); r.setRef( 0 ); r.setOffset( 0 ); r.setBlipRecord( blipRecord ); return workbook.addBSERecord( r ); }
Example 9
Source File: Md5Utils.java From cos-java-sdk-v5 with MIT License | 4 votes |
public static byte[] computeMD5Hash(InputStream is) throws IOException { return DigestUtils.md5(is); }
Example 10
Source File: CodecUtils.java From juice with Apache License 2.0 | 4 votes |
/** MD5 **/ public static byte[] md5(final String data) { return DigestUtils.md5(data); }
Example 11
Source File: HashCrypto.java From wind-im with Apache License 2.0 | 4 votes |
public static String MD5(String key) { byte[] md5Data = DigestUtils.md5(key); return Hex.encodeHexString(md5Data); }
Example 12
Source File: HashCrypto.java From openzaly with Apache License 2.0 | 4 votes |
public static String MD5(String key) { byte[] md5Data = DigestUtils.md5(key); return Hex.encodeHexString(md5Data); }
Example 13
Source File: HashCrypto.java From openzaly with Apache License 2.0 | 4 votes |
public static byte[] MD5Bytes(String key) { return DigestUtils.md5(key); }
Example 14
Source File: HashCrypto.java From openzaly with Apache License 2.0 | 4 votes |
public static String MD5(String key) { byte[] md5Data = DigestUtils.md5(key); return Hex.encodeHexString(md5Data); }
Example 15
Source File: Md5Utils.java From markdown-image-kit with MIT License | 4 votes |
/** * Computes the MD5 hash of the given data and returns it as an array of bytes. */ public static byte[] computeMD5Hash(byte[] input) { return DigestUtils.md5(input); }
Example 16
Source File: Md5Utils.java From markdown-image-kit with MIT License | 4 votes |
public static byte[] computeMD5Hash(InputStream is) throws IOException { return DigestUtils.md5(is); }
Example 17
Source File: OptifineSetup.java From OptiFabric with Mozilla Public License 2.0 | 4 votes |
byte[] fileHash(File input) throws IOException { try (InputStream is = new FileInputStream(input)) { return DigestUtils.md5(is); } }
Example 18
Source File: Md5Hash.java From rya with Apache License 2.0 | 4 votes |
public static byte[] md5Binary(final Value value) { return DigestUtils.md5(value.get()); }
Example 19
Source File: HashCrypto.java From wind-im with Apache License 2.0 | 4 votes |
public static byte[] MD5Bytes(String key) { return DigestUtils.md5(key); }
Example 20
Source File: EncryptUtil.java From EserKnife with Apache License 2.0 | 2 votes |
/** * MD5加密 * @param inStr 要加密的内容 * @return 加密后的结果 * @since 3.4 */ public static byte[] md5Encode(String inStr) { return DigestUtils.md5(inStr); }