[Pas2js] TJSCrypto name minor error

Michael Van Canneyt michael at freepascal.org
Mon Aug 12 14:52:03 CEST 2019



On Mon, 12 Aug 2019, Mattias Gaertner via Pas2js wrote:

> On Mon, 12 Aug 2019 14:38:46 +0200 (CEST)
> Michael Van Canneyt <michael at freepascal.org> wrote:
>
>> On Mon, 12 Aug 2019, warleyalex via Pas2js wrote:
>> 
>> > the original definition in Web.pas
>> > ===================================
>> > TJSCrypto = class external name 'Crypto'  (TJSObject)
>> >  private
>> >    Fsubtle: TJSSubtleCrypto; external name 'subtle';
>> >  Public
>> >    class procedure getRandomValues (anArray : TJSTypedArray);
>> >    property subtle : TJSSubtleCrypto Read Fsubtle;
>> >  end; 
>> > ===================================
>> >
>> > ... I need to access the getRandomValues method.
>> > e.g.
>> >    TJSCrypto.getRandomValues(data); 
>> >
>> > the method getRandomValues is not available!
>> >
>> > the minor error within name "crypto" definition, I believe the
>> > correct is:
>> >
>> > TJSCrypto = class external name 'crypto'  (TJSObject)
>> >
>> > to generate the correct output
>> > window.crypto.getRandomValues(array); 
>> 
>> Nono. You are accessing it wrong.
>> 
>> This is the code you should be using:
>> 
>> Window.crypto.getRandomValues(data);
>
> Then it should be " class external name 'Window.crypto' ", should it
> not?

No. The interface is called "Crypto".

The only instance of this interface is available through Window.Crypto.

You cannot create an instance of this class/interface.

Michael.


More information about the Pas2js mailing list