Jump to content

azrael_11

Members
  • Content Count

    69
  • Joined

  • Last visited

Posts posted by azrael_11


  1. 18 hours ago, pcplayer99 said:

    Hi,

     

    These code shows how to HASH signature by SHA1, but it is not show how to combine a signature string to HASH.

     

    I have not study Yahoo, but in MS Azure, it signature string is like:

     

     

    GET
    x-ms-date:Wed, 30 Jan 2019 15:12:26 GMT
    x-ms-version:2015-02-21
    /devstoreaccount1/devstoreaccount1/pcplayer1
    comp:list
    restype:container
    timeout:30
     
    And MS said that between every line, there is a LF(#10 or $A) but no Return(#13 or $D) char.
    So, you must know how Yahoo's signature string create.

     

    Maybe something like this in C++ code

    String signatureString = "GET&" +
                URLEncoder.encode(url, "UTF-8") + "&" +
    URLEncoder.encode(parametersList.toString(), "UTF-8");

    Thank you


  2. On 2/3/2019 at 10:19 PM, pcplayer99 said:

    Hi,

     

    These days I'm studying MS Azure. And I have used Delphi TAzureBlobService to access Azure, and its signature result can not accepted by Azure. To access Azure, it is by REST.

     

    I found that Azure returned some error message through HTTP, in the error message, Azure said: Server used following string to sign xxxxx xxxx。

     

    So, I use the string of the error message tell me to be a template, to create my signature string, and use the method from TAzureBlobService  to calculate the signature. It works!

     

    BTW. Azure's signature is calculate by SHA2:  THashSHA2.GetHMACAsBytes(StringToSign, Signkey, THashSHA2.TSHA2Version.SHA256);

     

    So, you may need to read Yahoo's information that its structure of signature string, and what calculation it use.

     

    This is the official String signature  generator that taken from C++ code  form Yahoo.

    But i cant translated to delphi code.

    String signature = null;
            try {
                SecretKeySpec signingKey = new SecretKeySpec((consumerSecret + "&").getBytes(), "HmacSHA1");
                Mac mac = Mac.getInstance("HmacSHA1");
                mac.init(signingKey);
                byte[] rawHMAC = mac.doFinal(signatureString.getBytes());
                Encoder encoder = Base64.getEncoder();
                signature = encoder.encodeToString(rawHMAC);
            } catch (Exception e) {
                System.err.println("Unable to append signature");
                System.exit(0);
    }

    Thank you

     


  3. Hi

    I Create an app for windows and i try to add forecast results on it.

     

    I use the Yahoo weather api but recently even the free access goes to  oauth1 Authorization.

     

    here what Yahoo wants to access forecast results.

     

    GET /forecastrss?location=sunnyvale,ca HTTP/1.1
    Host: weather-ydn-yql.media.yahoo.com
    Yahoo-App-Id: YOUR_APP_ID
    Authorization: OAuth
    oauth_consumer_key="YOUR_CONSUMER_KEY",oauth_signature_method="HMAC-SHA1",oauth_timestamp="YOUR_TIMESTAMP",oauth_nonce="YOUR_NONCE",oauth_version="1.0",oauth_signature="YOUR_GENERATED_SIGNATURE"
    cache-control: no-cache

     

    I go to REST Debugger tool provide by emb

    I add the get method in method url like this http://weather-ydn-yql.media.yahoo.com/forecastrss?w=2502265

    I select the from authentication the method oauth 1  and i put my Client-ID and the Client-Secret and select the HMAC-SHA1 from OAuth-Assistant.

     

    Now how can i add Timestamp, oauth_nonce,

     

    BCS when i execute the request i get

     

    Connection=keep-alive
    Date=Fri, 18 Jan 2019 08:32:06 GMT
    Via=http/1.1 media-router-omega65.prod.media.bf1.yahoo.com (ApacheTrafficServer [cMsSf ])
    Content-Length=0
    Content-Type=application/json;charset=UTF-8
    Age=0
    Server=ATS
    WWW-Authenticate=OAuth oauth_problem="OST_OAUTH_SIGNATURE_INVALID_ERROR", realm="yahooapis.com" //here i get an error
    X-Frame-Options=SAMEORIGIN
    X-Content-Type-Options=nosniff
    X-XSS-Protection=1; mode=block
    Referrer-Policy=no-referrer-when-downgrade

     

    Thank you.


  4. Hell and happy new year.

     

    2019 may be great year for delphi developers.

     

    First question of the year for me.

    Is out there and particle system for FireMonkey either 2D or 3D, free?

     

    I really make use of that for my program.

     

    Thank you.


  5. 12 hours ago, Dave Nottage said:

    What is the exact error message? Can you ping the address from a command line window in your VM?

     

    I'm using VirtualBox VM's myself and have not had an issue with either NAT or Bridged, as long as the VM can "see the address" being connected to.

    Finally i get it.

    The only thing is to reboot my pc and add bridged again and it works just fine.

     

    Thank you all.


  6. 1 hour ago, Микола Петрівський said:

    What type of network do you use in your VM? I have successfully used "NAT Network".

    I try almost all and Nat and briged nothing

     

    Do you know how can i know if my virtual machine is at my home network?

     

    Thank you.

     


  7. Hi

    I manage to setup a virtual box MacOsX high sierra machine

     

    I setup the network so the ip is always the 192.168.2.100

    I run the paserver.

    The ip i get when i execute the i command is the above 192.168.2.100

    The port i get when i execute the p command is the 64211

     

    I put this settings in the main machine and it fails ...

     

    Someone solve this....

     

    Thank you.


  8. On 12/9/2018 at 5:57 PM, David Heffernan said:

    Pointless to ask ShellExecute to create a cmd process to in turn create another process. Create the other process directly. This is the source of all your problems. 

    I think you are right about this so i make a process to call that...

     

    Thank you.


  9. 41 minutes ago, dummzeuch said:

    You quoted the whole command line, not just the program path.

     

    This is what I meant:

     

    
    ShellExecute(0, nil, 'cmd.exe', PChar('/C ' + AnsiQuotedStr(program_path, Char(34))+ ' -fg'), PChar(program_path), SW_HIDE);

     

     

    Like
    •  

    That work just fine.

     

    Thank you.


  10. 34 minutes ago, dummzeuch said:

    You should only quote the program path rather than the whole command line.

    I try this

    ShellExecute(0, nil, 'cmd.exe', PChar(AnsiQuotedStr('/C ' + program_path, Char(34))+ ' -fg'), PChar(program_path), SW_HIDE);

    Nothing, not working.

     


  11. Hello..

     

    When i execute this command

    var
    	program_path: string;
    begin
    program_path:= c:/myprogram.exe
    
    ShellExecute(0, nil, 'cmd.exe', PChar('/C ' + program_path+ ' -fg'), PChar(program_path), SW_HIDE);

     

    but when the program_path have a space like a "New folder"

    var
    	program_path: string;
    begin
    program_path:= c:/New Folder/myprogram.exe
    
    ShellExecute(0, nil, 'cmd.exe', PChar('/C ' + program_path+ ' -fg'), PChar(program_path), SW_HIDE);

    Then nothing happens . I try this

    ShellExecute(0, nil, 'cmd.exe', PChar(AnsiQuotedStr('/C ' + program_path+ ' -fg', Char(34))), PChar(program_path), SW_HIDE);

    Nothing.


  12. 1 hour ago, KodeZwerg said:

    What do you mean by this?

    Hook like a logger or something that activates by proper combination of hotkey?

    Wich Platforms should be supported?

    Wich Delphi you do use?

    I forget a lot so let me begin

     

    Not a logger i try to make something like this.

    When a user hit a key to another program i want to know what key is and make my procedure.

     

    Example :

    When run a game emulator like MAME when the user hit "t" in the keyboard when plays in mame i want to exit mame not execute the mame command that have in "t" key.

    So i can make a map of keys like arrow left to use it the joystick left. i hope i give you understand about that.

     

    The platforms i want to go is Win64, win32, MacOsx ... for now.

     

    I use the Delphi 10.2.3 Tokyo . FMX Platform.

     

    Thank you.

     

     

     

     

     


  13. After a few search i found a helper for the Imagelist and it is work just fine.

     

    Here the code below

    type
      TImageListHelper = class Helper for TImageList
        function Add(const ABitmap: TBitmap): integer;
      end;
    
    implementation
    
    function TImageListHelper.Add(const ABitmap: TBitmap): integer;
    const
      Scale = 1;
    var
      vSource: TCustomSourceItem;
      vBitmapItem: TCustomBitmapItem;
      vDest: TCustomDestinationItem;
      vLayer: TLayer;
    begin
      Result := -1;
      if (ABitmap.Width = 0) or (ABitmap.Height = 0) then
        exit;
      // add source bitmap
      vSource := Source.Add;
      vSource.MultiResBitmap.TransparentColor := TColorRec.Fuchsia;
      vSource.MultiResBitmap.SizeKind := TSizeKind.Source;
      vSource.MultiResBitmap.Width := Round(ABitmap.Width / Scale);
      vSource.MultiResBitmap.Height := Round(ABitmap.Height / Scale);
      vBitmapItem := vSource.MultiResBitmap.ItemByScale(Scale, True, True);
      if vBitmapItem = nil then
      begin
        vBitmapItem := vSource.MultiResBitmap.Add;
        vBitmapItem.Scale := Scale;
      end;
      vBitmapItem.Bitmap.Assign(ABitmap);
    
      vDest := Destination.Add;
      vLayer := vDest.Layers.Add;
      vLayer.SourceRect.Rect := TRectF.Create(TPoint.Zero, vSource.MultiResBitmap.Width,
        vSource.MultiResBitmap.Height);
      vLayer.Name := vSource.Name;
      Result := vDest.Index;
    end;

     

    Thank you for help

     


  14. 1 hour ago, Rollo62 said:

    I used something like this for testing purposes

    
    // Adds a new Bitmapitem to the ImageList acc. to InsertPos
    // iInsertPos = -1 = Append;  iInsertPos = Insert(iPos, ... insert before
    // ASrcRect defines the CropRect of the SourceBmp, which is used in Destination
    // Return the just added ImgList ID
    function  ImgList_Bitmap_Add(      iInsertPos   : Integer;
                                 const ADestImgList : TImageList;
                                 const ADestRect    : TRectF;
                                 const ASrcBmp      : TBitmap
                                ) : Integer;
    var
      isi: TSourceItem;
      idi: TDestinationItem;
      lay: TLayer;
      sSrcName: string;
      bmi: TBitmapItem;
      ms: TMemoryStream;
    
    begin
      Result := -1;
    
      if not Assigned(ADestImgList) or not Assigned(ASrcBmp) then
        Exit;
    
      if (ASrcBmp.Width = 0) or (ASrcBmp.Height = 0) then
        Exit;
    
    
      try
        // Create new Source entry
        if iInsertPos < 0 then
          isi := ADestImgList.Source.Add                as TSourceItem  // Append
        else
          isi := ADestImgList.Source.Insert(iInsertPos) as TSourceItem; // Insert before
    
        if not Assigned(isi) then
        begin
          Exit; // Somethings wrong
        end;
    
        // Create MultiResBitmap w/ LAyer
        if isi.MultiResBitmap.Count = 0 then
        begin
          bmi := isi.MultiResBitmap.Add as TBitmapItem;
    
          if not Assigned(bmi) then
          begin
            Exit; // Somethings wrong
          end;
    
          // Add the Bitmap via Stream, to allow Format settings
          ms := TMemoryStream.Create; // Copy Bmp via Stream, so that PNG-Format is possible
    
          try
            ASrcBmp.SaveToStream( ms );
            ms.Position := 0;
    
            bmi.Bitmap.CreateFromStream( ms );
    
          finally
            ms.Free;
          end;
    
        end;
    
        // Get the unique SourceItem Name
        sSrcName  := isi.Name;
    
        // Create new Destination entry
        if iInsertPos < 0 then
          idi := ADestImgList.Destination.Add                as TDestinationItem  // Append
        else
          idi := ADestImgList.Destination.Insert(iInsertPos) as TDestinationItem; // Insert before
    
        if not Assigned(idi) then
        begin
          Exit; // Somethings wrong
        end;
    
        // Add new Dest Layer, for output
        lay := idi.Layers.Add;
        if Assigned(lay) and (sSrcName <> '') then
        begin
          // Link the Layer with the Source, so that Output Bitmap is linked
          lay.Name := sSrcName;  // Setup the link the the Source Bitmap here
          lay.SourceRect.Rect   := ADestRect;  // Region which crops within the soure-Rect
    
          // Finally new Bitmap is in list, return the destination ID
          Result := idi.Index;
        end;
    
      finally
    
      end;
    
    end;

     

    Thank you i'll try this..

     


  15. Hello

    To our new home and hope last longer

     

    I have a question...

     

    I am working on an FMX Program and try to create a TImageList Dynamic and add Images into the "List of Images" so i can call the image from the Tstringgrid cell with the number ...

    Do you know how can i do this ?

    Thank you.

     

     

×