Jump to content

Quickly convert text to variables when brackets and parentheses are contained.


Trong
 Share

Recommended Posts

For each password containing brackets I need to add it manually, do you have a piece of code that quickly converts it to a variable to insert into the code? Please help

 

Example password file:

R7PIO'24NJ7'5OI2J6'O23L64P23"J624P46P;46Z7PIO2'4NJ75OI2J6O23Y64P23J6"24P"46P;46T7PIO24N'J75OI2J6'O23T64P"23"J624"P46P;46K

After converting:

$My_Password = "R7PIO'24NJ7'5OI2J6'O23L64P23" & '"J624P46P;46Z7PIO2' & "'4NJ75OI2J6O23Y64P23J6" & '"24P"46P;46T7PIO24N' & "'J75OI2J6'O23T64P" & '"23"J624"P46P;46K'

 

Regards,
 

Link to comment
Share on other sites

No, the password is not stored in the file.
The file here is for quick conversion only.
Because you can't paste it directly into the script, you need to save it to a file to convert it into a variable for quick copying into the script.

 

; BEGIN - Write Test file
Local $My_Password = "R7PIO'24NJ7'5OI2J6'O23L64P23" & '"J624P46P;46Z7PIO2' & "'4NJ75OI2J6O23Y64P23J6" & '"24P"46P;46T7PIO24N' & "'J75OI2J6'O23T64P" & '"23"J624"P46P;46K'
Local $My_Password_File = @ScriptDir & '\My_Password.txt'
FileWrite($My_Password_File, $My_Password)
; END - Write test file

Local $My_Password = FileRead($My_Password_File)
FileDelete($My_Password_File) ;  Remove test file

ConsoleWrite("- " & $My_Password & @CRLF)
Local $Pass_Process = ''
If StringInStr($My_Password, "'") And StringInStr($My_Password, '"') Then
    ConsoleWrite('>1 ' & $My_Password & @CRLF)
    $Pass_Process = '###' & $My_Password & '###'                  ;;????????????????????????;
ElseIf StringInStr($My_Password, "'") And (Not StringInStr($My_Password, '"')) Then
    ConsoleWrite('>2 ' & $My_Password & @CRLF)
    $Pass_Process = '"' & $My_Password & '"'
Else
    ConsoleWrite('>3 ' & $My_Password & @CRLF)
    $Pass_Process = "'" & $My_Password & "'"
EndIf
ConsoleWrite("-> $My_Password = " & $Pass_Process & @CRLF)

 

Edited by Trong

Regards,
 

Link to comment
Share on other sites

Then from where is the password obtained?

FYI, you can double up the quotation marks, ie --

$sPwd = "R7PIO'24NJ7'5OI2J6'O23L64P23""J624P46P;46Z7PIO2'4NJ75OI2J6O23Y64P23J6""24P""46P;46T7PIO24N'J75OI2J6'O23T64P""23""J624""P46P;46K"
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sPwd = ' & $sPwd & @CRLF & '>Error code: ' & @error & @CRLF)

 

Link to comment
Share on other sites

17 minutes ago, Danp2 said:

Maybe someone else will be better at deciphering your requirements.

I hope, I am :lol:

 

Local $My_Password   = "R7PIO'24NJ7'5OI2J6'O23L64P23" & '"J624P46P;46Z7PIO2' & "'4NJ75OI2J6O23Y64P23J6" & '"24P"46P;46T7PIO24N' & "'J75OI2J6'O23T64P" & '"23"J624"P46P;46K'
Local $dPasswordBin, $sPasswordStr
ConsoleWrite($My_Password & @CRLF)

$dPasswordBin = StringToBinary($My_Password)
ConsoleWrite($dPasswordBin & @CRLF)
ConsoleWrite(BinaryToString($dPasswordBin) & @CRLF)

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

I think OP wants to generate a command to assign a variable ($My_Password) the password string
if so then the best way would be to use double quotes to escape the single quotes (method 1)
but if OP doesn't like this way then he could replace the quotes with chr(34) (method 2)

If I didn't understand anything then sorry  :P

; BEGIN - Write Test file
Local $My_Password = "R7PIO'24NJ7'5OI2J6'O23L64P23" & '"J624P46P;46Z7PIO2' & "'4NJ75OI2J6O23Y64P23J6" & '"24P"46P;46T7PIO24N' & "'J75OI2J6'O23T64P" & '"23"J624"P46P;46K'
Local $My_Password_File = @ScriptDir & '\My_Password.txt'
FileWrite($My_Password_File, $My_Password)
; END - Write test file

$My_Password = FileRead($My_Password_File)
FileDelete($My_Password_File) ;  Remove test file
ConsoleWrite("-  " & $My_Password & @CRLF& @CRLf)

;  (method 1)
ConsoleWrite('-> $My_Password = "' & StringReplace($My_Password, '"', '""') & '"' & @CRLF)

;  (method 2)
ConsoleWrite('-> $My_Password = "' &  StringReplace($My_Password, '"', '" & Chr(34) & "') & '"' & @CRLF)

 

Edited by Gianni

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...