1. Yuri Denshchik
  2. PowerBuilder
  3. Thursday, 1 February 2018 19:24 PM UTC

To support Rest basic authentication, string has to be encoded in base-64. In Javascript there is btoa() method.

I cannot find corresponding method in PB2017 R2.

Please advise.

Thanks,

Yuri

 

Accepted Answer
Roland Smith Accepted Answer Pending Moderation
  1. Thursday, 1 February 2018 20:17 PM UTC
  2. PowerBuilder
  3. # Permalink

This example has base64 encode & decode functions:

http://www.topwizprogramming.com/freecode_bcrypt.html

 

Comment
  1. Yuri Denshchik
  2. Thursday, 1 February 2018 21:29 PM UTC
Works like a charm! 



Thank you Roland

  1. Helpful
There are no comments made yet.
Bjarne Anker Accepted Answer Pending Moderation
  1. Thursday, 24 September 2020 10:58 AM UTC
  2. PowerBuilder
  3. # 1

Also, base64 encoding/decoding is available in PB2019R2 using the CoderObject.

Works very good.

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Wednesday, 23 September 2020 15:27 PM UTC
  2. PowerBuilder
  3. # 2

I am pretty sure that the BCrypt API requires a user account so wouldn't work from IIS.

Try the Cryptoapi example instead.

Comment
  1. Antony Xavier
  2. Wednesday, 23 September 2020 16:46 PM UTC
Thank you very much for your quick reply and it is worked !!!
  1. Helpful
There are no comments made yet.
Antony Xavier Accepted Answer Pending Moderation
  1. Wednesday, 23 September 2020 15:12 PM UTC
  2. PowerBuilder
  3. # 3

Hi Rolland,

I download your code and try to "File" content  encode and decode, it is not working from webserver

following is the sample code, running from powerbuilder, can you help where is my mistake, tried from browser  as well as IWA runner, but no hope, no error is returning.

n_bcrypt in_bc
integer li_fnum,li_rtn
long ll_bytes
Boolean lb_rc
Blob lblob_content, lblob_Encoded, lblob_Decoded
String ls_Message, ls_Encoded, ls_Decoded,ls_source_file,ls_s_file,lss_path
//Read a file and store the content to lblob_Decoded

li_rtn = GetFileOpenName("Select File",ls_source_file, ls_s_file, "Doc", "All Files (*.*), *.*")

li_fnum = FileOpen(ls_source_file , StreamMode!)
ll_bytes = FileReadEx(li_fnum, lblob_content )
messagebox('Read', string(ll_bytes))
//encoding to string
fileclose(li_fnum)
lb_rc = in_bc.of_Base64Encode(lblob_content, ls_Encoded)

if lb_rc then messagebox ( 'lb_rc', 'encode true' ) else messagebox ( 'lb_rc', 'encode False' )

if isnull(ls_Encoded) then ls_Encoded = ''
messagebox('Encode', string(ls_Encoded))

//decoding encoded string to blob

lb_rc = in_bc.of_Base64Decode(ls_Encoded, lblob_Decoded)
if lb_rc then messagebox ( 'lb_rc', 'decode true' ) else messagebox ( 'lb_rc', 'decode False' )

lss_path += "\" + ls_s_file
//
lss_path = ls_source_file+'123'
li_fnum = FileOpen( lss_path, Textmode!,Write!,LockReadWrite!,Replace!)
ll_bytes = FileWriteEx ( li_fnum, lblob_Decoded)
FileClose ( li_fnum )
messagebox('write', string(ll_bytes))
messagebox('write', string(lss_path))
//write lblob_Decoded content to a file and try to open

 

/////////////////////////////////////////////////////////////////////////////

Regards

Antony

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.