Maxscript Encoding and BOM


#1

I’m having trouble reading the username and password.

Username: “user”
Password: “123456”

Thank you very much in advance.

Regards best.

screenshot_forencodingproblem

--Writer Func
TextFileName = getdir  #temp + "\\render724_credentials.txt"
TextFile = (openFile TextFileName mode:"w+")
if  not existFile TextFileName do  TextFile = (createFile TextFileName  encoding:#utf8 writeBOM:true)
username_and_password = user + " " + pass
enc_credentials = base64encode username_and_password
format enc_credentials to: TextFile
close TextFile

--Reader Func
TextFileName = getdir  #temp + "\\render724_credentials.txt"
TextFile = (openFile TextFileName mode:"r+"  encoding:#utf8 writeBOM:true)
enc_credentials = readline TextFile
close TextFile
dec_credentials = base64decode enc_credentials
print dec_credentials

--ERROR:
-- MAXScript Rollout Handler Exception:
-- Runtime error: dotNet runtime exception: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters. 
-- MAXScript callstack:
--	thread data: threadID:19044
--	------------------------------------------------------
--	[stack level: 0]
--	In base64decode(); filename: \\FILESERVER\Backup\_temp\maxscript\test_log_nonsubmit.ms; position: 7409; line: 221
--	member of: Rollout:SimpleSubmitter_Rollout
--		Parameters:
--			str: "dXNlciAxMjM0NTY=" <-- This is the place located in the screenshot.
--		Locals:
--			str: "dXNlciAxMjM0NTY=" <-- This is the place located in the screenshot.
--			dncConvert: dotNetClass:System.Convert
--			dnvStringOut: undefined
--			dnvByteArrayOut: undefined
--			dnoUTF8: dotNetObject:System.Text.UTF8Encoding
--		Externals: