Forum > General
Compare strange characters (decryption)
nikel:
Hello, I'm trying to decrypt password box input. I have this encrypted password in a file:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---èåQ:÷¯U
But when I load the file into stringlist I'm getting:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---??Q:?U
How can I correctly load my file?
cdbc:
Hi
That looks like a codepage issue e.g.: cp1252 -> UTF8 can result in ?
Have a look in package LazUtils, more specifically in LazUTF8 et.al. (LConvEncoding etc.)
Regards Benny
nikel:
Thank you for your reply. I'm already using UTF8:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- if (OpenDialog1.Execute) then begin try ListOfImport.LoadFromFile(OpenDialog1.FileName, TEncoding.UTF8); except on E: Exception do raise Exception.Create(E.ClassName + #13 + E.Message); end; end;
cdbc:
Hi
Yup, but that doesn't help if your file on disc is cpiso8859-1, then your TEncoding.UTF8 will try to load it as UTF8 and that produces ? ? ?
Somewhere in lazutils there's a function "DetectCodepage" or "GuessCodepage/Encoding", which will try to find the right cp.
...or try something like this:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function ISO_8859_15ToUTF8(const s: string): string; from LConvEncoding on the string when you have loaded it(without TEncoding.UTF8)...
Regards Benny
kwyan:
My understanding is your data is encrypted password. It means it not UTF8 characters. So you save these into file or read it to the program, you must keep on using cp1252.
Navigation
[0] Message Index
[#] Next page