Giter Site home page Giter Site logo

Comments (6)

danog avatar danog commented on August 21, 2024

This isn't working because you're not passing a long to the nonce parameter, but a random string.
To turn it into a long you need to unpack it using the <q parameter of PHPStruct (see how I did it in the above functions).

from madelineproto.

2012mjm avatar 2012mjm commented on August 21, 2024

Do you mean this following code

$nonce = \phpseclib\Crypt\Random::string(16);
$nonceToLong = $this->struct->unpack('<q', $nonce);
echo $nonceToLong;

Fatal error: Uncaught exception 'danog\PHP\StructException' with message 'Length of given data (16) is different from length calculated using format string (8).

from madelineproto.

danog avatar danog commented on August 21, 2024

@2012mjm You need to generate a random string of 8 bytes to convert it to a long

from madelineproto.

danog avatar danog commented on August 21, 2024
$nonceToLong = $this->struct->unpack('<q',  \phpseclib\Crypt\Random::string(8)); // Do not declare variables that are only going to be used once
echo $nonceToLong;

from madelineproto.

2012mjm avatar 2012mjm commented on August 21, 2024

this is ok

from madelineproto.

danog avatar danog commented on August 21, 2024

I made it work. Yay!

from madelineproto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.