OrientDB ??????? NoSQL ???,????????,????????????? OrientDB ?,???????????????????????????????????,????????:
- ????????:?????????? OrientDB ??,????????(?? MD5 ? SHA-1)???????????????,???????????????????,???????????????????,??????????
import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public static String calculateHash(byte[] data) { try { MessageDigest md = MessageDigest.getInstance("MD5"); md.update(data); byte[] hashBytes = md.digest(); StringBuilder sb = new StringBuilder(); for (byte b : hashBytes) { sb.append(String.format("x", b)); } return sb.toString(); } catch (NoSuchAlgorithmException e) { throw new RuntimeException("Error calculating hash", e); } }
- ?? OrientDB ?????:OrientDB ?????????,?
MD5()
?SHA1()
,???????????????????????????????,????????????????(??,?? Base64 ??),?????????
-- ?????????? MD5 ??? INSERT INTO binary_data (id, content, md5) VALUES (1, 'base64EncodedString', MD5('base64EncodedString')); -- ??????? MD5 ??? SELECT id, content, MD5(content) AS computed_md5 FROM binary_data WHERE id = 1;
- ??????:?????????????????????????????,Java ??? Apache Commons Codec ?,??????? Base64 ??? MD5 ???
??,???? OrientDB ???????,???????????????,?????????????????????????????????????