Is there any way to store string values as stream data?

+1 vote
There are two methods to publish data into a stream, namely publish and publishfrom. In both the cases we need to store a hex (say hash of actual string or any other hash) value. Is there any way to store string value as is in stream with out creating another transaction or putting the value in another storage?
asked Jan 10, 2017 by Debu

1 Answer

+1 vote
Yes, just convert the string to hexadecimal before passing it to the API. Most languages will have a function to do this. The hexadecimal format is only for the sake of the API, since it's hard to send/receive binary data in the JSON-RPC format. Within the stream the data is stored in raw binary form in any case.
answered Jan 10, 2017 by MultiChain
Can you Please share any example for the same. in java(preferable ) or any other code.
If you need a single conversion for testing purposes I can recommend this:
Otherwise just google for "java convert string to hex".
In Python 3 you can use s.encode('utf-8').hex() where s is your string and you get a string containing the hex-representation of string s.