Decoding blob data from a sqlite database into a human readable text

好久不见. 提交于 2019-12-02 11:43:24

问题


I have a Sqlite database file that has blob data in it. I only know the the database has blob data and I know what the expected output should be. The blob data's expected output should be a Mac address with other text.

I tried getting the hex output but does not really help me with getting the expected output that I know is in the database. I also used a Hex editor and sqlite viewer but only shows gibberish unreadable text.

Here is some code that I tried to get the bytes from the blob data but does not produce the output I expected. Sqlite doesn't have the getBlob function in Java.

if (rs.next()) {
    byte[] buffer = rs.getBytes(1);
    System.out.println(buffer.toString());
}

An expected output from the blob should be :" JOHN A6:44:33:A4:G5:A4 "

Here is a sample Hex dump 0008f473eb41 e8ba3b1c

How can I programattically retrieve the blob data and decode the contents of the blob in sqlite?


回答1:


Right now you are printing a byte[] array toString(). Arrays in Java don't implement in meaningful way.

You can try converting the byte[] array into a String with:

new String(buffer, Charsets.UTF_8)

If this doesn't work use rs.getBinaryStream(1) to get the InputStream representing the value and read it as per this answer.



来源:https://stackoverflow.com/questions/55729744/decoding-blob-data-from-a-sqlite-database-into-a-human-readable-text

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!