AnsweredAssumed Answered

JSONSetElement/JSONGetElement Bug with Base64 Encoding

Question asked by TobiasLiebhartKoschierSE on Sep 5, 2018
Latest reply on Sep 11, 2018 by TobiasLiebhartKoschierSE

When encoding something in Base64 and storing it in a JSON Structure and then retrieving the Value again the value has changed and is no longer the same. JSON loses characters which leads to faults with encryption parameters.

 

let (

[

    digest = Base64Encode ( CryptDigest ( "TEST" ; "SHA256") ) ;

    store = JSONSetElement ( "" ; "value" ; digest ; JSONString )

] ;

    List (

        JSONGetElement ( store ; "value" ) = Base64Encode ( CryptDigest ( "TEST" ; "SHA256") ) ;

        digest ;

        JSONGetElement ( store ; "value" ) ;

        Code ( digest ) ;

        code ( JSONGetElement ( store ; "value" ) )

    )

)

 

returns

 

0

lO4FkzXlh+UBzEv5BhPggU8Ap7CLx8ZI/YZaKvaiLMI=

 

 

lO4FkzXlh+UBzEv5BhPggU8Ap7CLx8ZI/YZaKvaiLMI=

 

 

10000130006100073000770007600105000970011800075000970009000089000470007300090000560012000076000670005500112000650005600085001030010300080001040006600053001180006900122000660008500043001040010800088001220010700070000520007900108

130006100073000770007600105000970011800075000970009000089000470007300090000560012000076000670005500112000650005600085001030010300080001040006600053001180006900122000660008500043001040010800088001220010700070000520007900108

 

 

as you can see there is a difference concerning non printable characters. That creates problems with decoding later on.

 

Basically the "10000" at the start of the Base64 encoded digest is lost

Outcomes