I have an API, the API returns the input like this:
{"phrase":"decrypted","parsed":"encryptedcode","response":"done","code":6}
Everything around "decrypted" and "encryptedcode" stays the same.
I need to get the "decrypted" part only. No idea where to even begin.
I'm using WebBrowser, since I'm not any good at HttpWebRequest, so if you could answer as WebBrowser code instead of HttpWebRequest, I would appreciate it.
Answer
clean = WebBrowser1.Document.Body.InnerText.Replace("phrase", "").Replace(":", "").Replace("parsed", "").Replace(md5, "").Replace("code", "").Replace("The MD5 hash was cracked.", "").Replace("""", "").Replace("6", "").Replace("}", "").Replace("{", "").Replace(",", "").Replace("response", "")
so I could do
listbox.items.add(clean)
and it wouldn't look messy.
Just Replace : to ,
Then you input looks like
{"phrase", "decrypted", "parsed", "encryptedcode", "response", "done", "code", 6}
then do as below
Dim str() As String = {"phrase", "decrypted", "parsed", "encryptedcode", "response", "done", "code", 6}
Dim decrypted As String = str(1)
you get Decrypted part
Related
I have my below code which works proper on 106.15, I get a succesfull status. Project is Visual Studio 2022 (.Net 4.8)
accessToken = GetAccessToken()
Dim rRequest As RestRequest
Dim rClient As RestClient
Dim rResponse As RestResponse
Try
Dim data() As Byte = File.ReadAllBytes(fileSource)
rClient = New RestClient("https://graph.microsoft.com/v1.0")
rRequest = New RestRequest(uploadURL, Method.Put)
rRequest.AddHeader("Authorization", "Bearer " & accessToken)
rRequest.AddHeader("Content-Range", New ContentRangeHeaderValue(0, data.Length - 1, data.Length).ToString)
rRequest.AddHeader("Content-Length", data.Length)
rRequest.AddParameter("application/binary", data, ParameterType.RequestBody)
rResponse = Await rClient.ExecuteAsync(rRequest)
When I execute the code on 107.15 it fails with the following error : There was an error sending the request (translated from dutch)
Any idea what could be wrong or should be changed?
Looks like 108.0.1 fixes the issue, it is working now.
This commit from 03 Mar 22 shows the fix.
Please read the documentation.
Don't use this:
rRequest.AddHeader("Content-Range", New ContentRangeHeaderValue(0, data.Length - 1, data.Length).ToString)
rRequest.AddHeader("Content-Length", data.Length)
rRequest.AddParameter("application/binary", data, ParameterType.RequestBody)
use AddFile instead.
You can still add the Content-Range header manually using AddHeader. As you aren't uploading the file (although you kind of do), you might not the file name to be there. In that case, you can try this:
rRequest
.AddBody(data)
.AddHeader("Content-Range", New ContentRangeHeaderValue(0, data.Length - 1, data.Length).ToString())
When AddBody gets a byte array, it will use the application/binary content type, and set the length correctly.
I want to convert text into the WWW form.
E.g: # should be %40, % should be %25 etc...
There's fine encoder here, but i want to do it in VB.Net.
I need this for httpwebrequest, i think it has something to do with x-www-form-urlencoded.
You can use the Uri.EscapeDataString() method for that:
Dim OriginalURL As String = "http://www.example.com/some file with spaces.php?q1=plus+&q2=at#&q3=svenska språkets 'ö'"
Dim EncodedURL As String = Uri.EscapeDataString(OriginalURL)
Online test: https://ideone.com/h5fqm1
And if you want to just escape parts of the URL but still keep valid components such as : / = ? & (etc.) you'd use Uri.EscapeUriString().
I'm trying to translate a JavaScript application of TOTP to VB.Net: http://blog.tinisles.com/2011/10/google-authenticator-one-time-password-algorithm-in-javascript/
I have encountered a problem during translation of the HMAC-part:
//Javascript:
var hmacObj = new jsSHA("Hello World!", 'HEX');
var hmac = hmacObj.getHMAC("secret", 'HEX', 'SHA-1', "HEX");
This is a codesnippet of my translation in VB.Net
'VB.Net:
Dim hmacObjTest As New HMACSHA1(System.Text.Encoding.UTF8.GetBytes("secret"))
Dim hmacTest As Byte() = hmacObjTest.ComputeHash(System.Text.Encoding.UTF8.GetBytes("Hello World!"))
Dim hmacHexTest As New StringBuilder()
For i As Integer = 0 To hmacTest.Length - 1
hmacHexTest.Append(hmacTest(i).ToString("x2"))
Next i
Dim strTest As String = "HMAC = " & hmacHexTest.ToString()
The problem is that i get different output from the two languages:
Output JS: 5efed98b0787c83f9cb0135ba283c390ca49320e //Tested from jsSha demo: http://caligatio.github.io/jsSHA/
Output VB.Net: 87b0154b8420c0b58869ca103f481e824d8876ea
The outputs are not at all the same like they are in this question: hmacsha1 output hex strings different between vb.net and python
Does anyone know where I might be doing something wrong?
Hashes don't work on strings - they work on the binary representation of the string. Now you use UTF-8 as encoding for the dotnet version, while the JavaScript version is very likely not to use UTF-8 - so you get different binary representations, resulting in different hashes.
Use either webttolkit or the hackish var utfstring = unescape(encodeURIComponent(rawstring)); to convert to UTF-8 before calcualting the hash.
I know it's a stupid question but I cannot find info about it.
Public Function TestFunc() As String
Dim lMapper = cRouter.StaticPortMappingCollection
Dim lMappedPort As NATUPNPLib.IStaticPortMapping
Dim Test As String
Test = lMapper.Add(80, "UDP", 8080, "192.168.1.100", True, "Local Web Server").ToString
MsgBox(Test)
End Function
lMapper.Add will return something like here S_OK and etc -> http://msdn.microsoft.com/en-us/library/aa366148(v=vs.85).aspx
How to get this value? By my way I get *System.__ComObject* ;[
Thank you very much for an answer.
You just need to cast it to an IStaticPortMapping like this
lMappedPort = DirectCast(lMapper.Add(80, "UDP", 8080, "192.168.1.100", True, "Local Web Server"), IStaticPortMapping)
I'm trying to send a 28 character string to a remote ip address and port. I've done this successfully in vb.net using the following code snippets:
Dim swon As String = "A55A6B0550000000FFFBDE0030C8"
Dim sendBytes As [Byte]()
sendBytes = Encoding.ASCII.GetBytes(swon)
netStream.Write(sendBytes, 0, sendBytes.Length)
I now have to convert this across to c++ and have the following so far:
char *swon = "A55A6B0550000000FFFBDE0030C8";
array<Byte>^ sendBuffer = gcnew array<Byte>(bufferSize);
sendBuffer = BitConverter::GetBytes( swon );
tcpStream->Write(sendBuffer, 0, sendBuffer->Length);
but am getting stuck at this point. I'm sure I'm missing a simple syntax error but I can't figure it out!
To clarify, I'm not getting an error, but I don't think the string is being converted to bytes correctly as when I convert back, I just get a '01'
Cheers,
Chris
I don't understand why you are not just using the exact same .Net framework classes in your ++/CLI code. eg. System::String for swon, Encoding::ASCII to produce the array of bytes.
Anything you did in VB you can map directly over to C++/CLI without using different classes - that's the easest port for you. When you are in MSDN online, just select the C++ view to get examples of stuff you want to do. Try that on this page, for example: http://msdn.microsoft.com/en-us/library/system.text.encoding.ascii.aspx
Steve is correct that the same logic can be duplicated in C++. But the C++ char* already is ASCII, no conversion is necessary. Just a copy is all that's needed.
const char swon[] = { "A55A6B0550000000FFFBDE0030C8" };
array<Byte>^ sendBuffer = gcnew array<Byte>((sizeof swon) - 1);
pin_ptr<Byte> startBuffer = &sendBuffer[0];
memcpy(startBuffer, swon, sendBuffer->Length);
tcpStream->Write(sendBuffer, 0, sendBuffer->Length);