Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question please? #23

Open
eliezercazarestravelport opened this issue Aug 5, 2023 · 2 comments
Open

Question please? #23

eliezercazarestravelport opened this issue Aug 5, 2023 · 2 comments

Comments

@eliezercazarestravelport

I need to save a JSON object to a Redis Database.

I am able to save, but I can't decrypt back from Redis.

It seems like I need to add a Stream Identifier to the compressed string to indicate it's a Snappy type.

`
/**
* All streams should start with the "Stream identifier", containing chunk
* type 0xff, a length field of 0x6, and 'sNaPpY' in ASCII.
*/
private static final byte[] STREAM_START = {
(byte) 0xff, 0x06, 0x00, 0x00, 0x73, 0x4e, 0x61, 0x50, 0x70, 0x59
};

`

This is the class the guys in Java are using..
https://programtalk.com/vs/?source=netty/codec/src/main/java/io/netty/handler/codec/compression/SnappyFrameEncoder.java

My question is, how can I generate a stream with those characteristics?

The rest of the payload it's a json object.

I.e.

const jsonObjectBody = '{ "myObjKey": "myObjValue" }';
const jsonObjectBodyStreamWithStreamIdentifier = ?????

Thank you very much!

@eliezercazarestravelport
Copy link
Author

Update:

The library works fine, very fine. But the Snappy encoding I need to do should return the stream identifier as follows:
"\x82SNAPPY\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00"

instead of:

�\x06\x00\x00sNaPpY\x00�\x03\

I wonder how to achieve the identifier as in the first example?

@eliezercazarestravelport
Copy link
Author

Update: The encoding in the server side was using Java-only encoding. Not an issue .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant