Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

SRP_Encode

I am trying to use a REST API that does not like the CRLF tagged and the end of my authorization. The encoding is BASE64. I am trying to use the option but am having a problem.
SRP_Encode(Data, 'BASE64') runs just fine
SRP_Encode(Data, 'BASE64',, 0) Returns a compile error , illegal expression encountered. No quote marks in third parameter
SRP_Encode(Data, 'BASE64', '', 0) This compiles okay but when executed fails with the following error image attached I updated SRP_Utilities by installing the new editor and I now get this error in the image titled capture2

I would like to verify that I am using the tool properly and if I am then turn it over to SRP

Comments

  • edited July 2016
    That is a bug on my part. I added that feature ages ago, but I must have lost the changes to a GFE or something. At any rate, I re-added that feature for the next release. You can try it out by download the pre-release build here. It's a ZIP file with the RDK. Just do an RDKINSTALL on it and you should be good to go.
  • edited July 2016
    I downloaded and tested 158RC1. SRP_Encode no longer crashes when using the options variable. I have confirmed that the CRLF is being stripped.

    When I inspect the variable created with the option to strip the CRLF in the OI debugger the Modify Variable screen displays characters. When I inspect the variable created without the option to strip the CRLF in the OI debugger the Modify Variable screen displays in hex. That would be an indication that the CRLF has been stripped. I confirmed this by checking the length of the variables. The one with the option to strip the CRLF is two characters shorter as would be expected.

  • I wonder if your test was using a bit too small of a data set. In my tests, I always got the Inspect Variable window instead of the Hex view. At any rate, I had code that would count CRLFs (or temporarily convert them to @FMs). That might be the most accurate means of confirmation. Also, since you are using this in the context of web APIs, you can also take a look at it in Postman to see how it looks when actually sent.
  • edited July 2016
    I used the following code to test an image:

    PicturePath = 'C:\AboutBanner.png' If Len(PicturePath) then OSRead PictureBinary from PicturePath then EncodedWithCRLF = SRP_Encode(PictureBinary, 'BASE64') Len1 = Len(EncodedWithCRLF) NumLF1 = Count(EncodedWithCRLF, \0A\) EncodedWOCRLF = SRP_Encode(PictureBinary, 'BASE64', '', 0) Len2 = Len(EncodedWOCRLF) NumLF2 = Count(EncodedWOCRLF, \0A\) end end
Sign In or Register to comment.