Google recaptcha v2 encryption in vb.net

2020-03-25 03:25发布

问题:

I am attempting to implement the secure token version of Googles Recaptcha v2, I have successfully implemented the single site version. The issue is we will need multiple domains to validate with the same key. Following the documentation here, has left me scratching my head. The "Encrypt your string" area is a bit vague for a new user (me). I have tried using standard AES encryption with my own salt but with no luck, I am met with ERROR: Invalid stoken

Working with this post AES encryption/decryption has yeilded some results with encryption and decryption but I get the same error message in recaptcha.

To try and test the encryption I am following what was posted in the bottom answer How to generate a Google ReCaptcha V2 secure token with PHP?

Has anyone gotten this working in VB.NET? My code currently is block for block what is in those two posts, following the second post I am getting the following outputs:

  • Json: {"session_id":"1","ts_ms":1437712654577}

  • Site Secret: 3330MgoTAAA333XFM388zn66iPtjOdQgREfZAgqZ

  • Encryption: Ly32WGlavKyWBDBIip5IRHdZMCaeIe1077RJQ1sQ17UzNOj1SmvBQVipj3mGI32d

You can see the format of the encryption is off, at least from what is suggested in that SO post.

Cheers

回答1:

I have created a working example of Recaptcha V2 secure token exchange here:

RecaptchaV2.NET

It is in C#, but you can use your favorite online C# to VB .NET code converter to get it translated to VB.