MD5加密

@param data 明文字符串
@param salt 盐
@return 16进制加盐密文
434787
public static String md5(String data, String salt) {
        return bytes2HexString(md5ToByte((data + salt).getBytes()));
    }
481800
public static String encryptMD5(String data) {
        try {
            MessageDigest digest = MessageDigest.getInstance("MD5");
            return copyValueOf(Hex.encodeHex(digest.digest(data.getBytes(StandardCharsets.UTF_8))));
        } catch (final NoSuchAlgorithmException ex) {
            throw new TechnicalException("Failed to instantiate an MD5 algorithm", ex);
        }
    }
1094683
function _md5( message ) {
    const hash = crypto.createHash( 'md5' );
    hash.update( message );
    return hash.digest( 'hex' );
}
198135
function encrypt(salt, password) {
    var hash = crypto.createHash('sha256').update(salt + password).digest('base64');
    return salt + hash;
}
906329
public QrCodeEncoder addBytes(byte[] data) {
		StringBuilder builder = new StringBuilder(data.length);
		for (int i = 0; i < data.length; i++) {
			builder.append((char)data[i]);
		}

		MessageSegment segment = new MessageSegment();
		segment.message = builder.toString();
		segment.data = data;
		segment.length = data.length;
		segment.mode = QrCode.Mode.BYTE;

		segment.encodedSizeBits += 4;
		segment.encodedSizeBits += 8*segment.length;

		segments.add(segment);

		return this;
	}
792374
public static byte[] md5(InputStream in) throws IOException {
		MD5InputStream md5in=new MD5InputStream(in);
		byte[] trashBuffer = BufferManager.getBytes();
		try {
			while(md5in.read(trashBuffer, 0, BufferManager.BUFFER_SIZE) != -1) {
				// Intentional empty block
			}
		} finally {
			BufferManager.release(trashBuffer, false);
		}
		return md5in.hash();
	}
326569
public static String md5(String str) {
		String md5 = encode(str, "MD5").toLowerCase();
		return md5;
	}
124205
public static String shaBase64(final String salt, final String data) {
        return shaBase64(salt, data, null);
    }
1132239
public static MD5Hash digest(InputStream in) throws IOException {
    final byte[] buffer = new byte[4*1024]; 
    int fileLength = 0;

    final MessageDigest digester = DIGESTER_FACTORY.get();
    for(int n; (n = in.read(buffer)) != -1; ) {
      digester.update(buffer, 0, n);
      fileLength += n;
    }

    return new MD5Hash(digester.digest(), fileLength);
  }
358216
def encrypt(data)
      Digest::const_get(algorithm.upcase).hexdigest(build(data, salt))
    end
1000943
public static BIG hashModOrder(byte[] data) {
        HASH256 hash = new HASH256();
        for (byte b : data) {
            hash.process(b);
        }

        byte[] hasheddata = hash.hash();

        BIG ret = BIG.fromBytes(hasheddata);
        ret.mod(IdemixUtils.GROUP_ORDER);

        return ret;
    }
448879
function md5(data, digest) {
            var hash = "";

            if (!digest) { digest = 'binary'; }

            if (digest === 'buffer') {
                digest = undefined;
                // todo: 不支持 buffer 类型的 hash
                return "";
            }

            if (typeof data === 'string') {
                switch (digest) {
                    case "binary":
                        return SparkMD5.hash(data, true);
                    case "hex":
                        return SparkMD5.hash(data);
                    case "base64":
                        return TableStore.util.hexToBase64(SparkMD5.hash(data));
                    default:
                        return "";
                }
            }
            else {  // array buffer
                switch (digest) {
                    case "binary":
                        return SparkMD5.ArrayBuffer.hash(data, true);
                    case "hex":
                        return SparkMD5.ArrayBuffer.hash(data);
                    case "base64":
                        return TableStore.util.hexToBase64(SparkMD5.ArrayBuffer.hash(data));
                    default:
                        return "";
                }
            }
        }
557985
public static byte[] sha1X16(String data, String encoding) {
		byte[] bytes = sha1(data, encoding);
		StringBuilder sha1StrBuff = new StringBuilder();
		for (int i = 0; i < bytes.length; i++) {
			if (Integer.toHexString(0xFF & bytes[i]).length() == 1) {
				sha1StrBuff.append("0").append(
						Integer.toHexString(0xFF & bytes[i]));
			} else {
				sha1StrBuff.append(Integer.toHexString(0xFF & bytes[i]));
			}
		}
		try {
			return sha1StrBuff.toString().getBytes(encoding);
		} catch (UnsupportedEncodingException e) {
			LogUtil.writeErrorLog(e.getMessage(), e);
			return null;
		}
	}
430952
public static byte[] SHA256(byte[] data) {
        Digest sha256 = createSHA256();
        sha256.update(data, 0, data.length);
        byte[] res = new byte[32];
        sha256.doFinal(res, 0);
        return res;
    }
575919
function sha256(data) {
    if (!data.byteLength) {
        return Promise.resolve(ByteUtils.arrayToBuffer(ByteUtils.hexToBytes(EmptySha256)));
    }
    if (subtle) {
        return subtle.digest({ name: 'SHA-256' }, data);
    } else if (nodeCrypto) {
        return new Promise(function(resolve) {
            var sha = nodeCrypto.createHash('sha256');
            var hash = sha.update(Buffer.from(data)).digest();
            resolve(hash.buffer);
        });
    } else {
        return Promise.reject(new KdbxError(Consts.ErrorCodes.NotImplemented, 'SHA256 not implemented'));
    }
}
404757
public static String shaBase64(final String salt, final String data, final String separator, final boolean chunked) {
        val result = rawDigest(MessageDigestAlgorithms.SHA_1, salt, separator == null ? data : data + separator);
        return EncodingUtils.encodeBase64(result, chunked);
    }
1181414
public static int hash32(final long data, int seed) {
        // 'm' and 'r' are mixing constants generated offline.
        // They're not really 'magic', they just happen to work well.
        final int m = 0x5bd1e995;
        final int r = 24;

        // Initialize the hash to a random value
        final int length = 8;
        int h = seed^length;

        for (int i=0; i<2; i++) {
            int k = (i==0) ? (int) (data & 0xffffffffL) : (int) ((data >>> 32) & 0xffffffffL);
            k *= m;
            k ^= k >>> r;
            k *= m;
            h *= m;
            h ^= k;
        }
        
        h ^= h >>> 13;
        h *= m;
        h ^= h >>> 15;

        return h;
    }