Skip to content

Update #18

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 6 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 32 additions & 25 deletions TwoCaptcha.Examples/RotateExample.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
using System;
using System.Linq;
using TwoCaptcha.Captcha;

namespace TwoCaptcha.Examples
{
public class RotateExample
{
public void Main()
{
TwoCaptcha solver = new TwoCaptcha("YOUR_API_KEY");

Rotate captcha = new Rotate("../../resources/rotate.jpg");

try
{
solver.Solve(captcha).Wait();
Console.WriteLine("Captcha solved: " + captcha.Code);
}
catch (AggregateException e)
{
Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
}
}
}
using System;
using System.IO;
using System.Linq;
using TwoCaptcha.Captcha;

namespace TwoCaptcha.Examples
{
public class RotateExample
{
public void Main()
{
TwoCaptcha solver = new TwoCaptcha("YOUR_API_KEY");

byte[] bytes = File.ReadAllBytes("../../resources/rotate.jpg");
string base64EncodedImage = Convert.ToBase64String(bytes);
Console.WriteLine("base64EncodedImage: " + base64EncodedImage);


Rotate captcha = new Rotate();
captcha.SetBase64(base64EncodedImage);

try
{
solver.Solve(captcha).Wait();
Console.WriteLine("Captcha solved: " + captcha.Code);
}
catch (AggregateException e)
{
Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
}
}
}
}
34 changes: 0 additions & 34 deletions TwoCaptcha.Examples/RotateManyExample.cs

This file was deleted.

72 changes: 35 additions & 37 deletions TwoCaptcha.Examples/RotateOptionsExample.cs
Original file line number Diff line number Diff line change
@@ -1,38 +1,36 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using TwoCaptcha.Captcha;

namespace TwoCaptcha.Examples
{
public class RotateOptionsExample
{
public void Main()
{
TwoCaptcha solver = new TwoCaptcha("YOUR_API_KEY");

var images = new List<FileInfo>();
images.Add(new FileInfo("../../resources/rotate.jpg"));
images.Add(new FileInfo("../../resources/rotate_2.jpg"));
images.Add(new FileInfo("../../resources/rotate_3.jpg"));

Rotate captcha = new Rotate();
captcha.SetFiles(images);
captcha.SetAngle(40);
captcha.SetLang("en");
captcha.SetHintImg(new FileInfo("../../resources/rotate_hint.jpg"));
captcha.SetHintText("Put the images in the correct way up");

try
{
solver.Solve(captcha).Wait();
Console.WriteLine("Captcha solved: " + captcha.Code);
}
catch (AggregateException e)
{
Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
}
}
}
using System;
using System.IO;
using System.Linq;
using TwoCaptcha.Captcha;

namespace TwoCaptcha.Examples
{
public class RotateOptionsExample
{
public void Main()
{
TwoCaptcha solver = new TwoCaptcha("YOUR_API_KEY");

byte[] bytes = File.ReadAllBytes("../../resources/rotate.jpg");
string base64EncodedImage = Convert.ToBase64String(bytes);


Rotate captcha = new Rotate();
captcha.SetBase64(base64EncodedImage);
captcha.SetAngle(40);
captcha.SetLang("en");
captcha.SetHintImg(new FileInfo("../../resources/rotate.jpg"));
captcha.SetHintText("Put the images in the correct way up");

try
{
solver.Solve(captcha).Wait();
Console.WriteLine("Captcha solved: " + captcha.Code);
}
catch (AggregateException e)
{
Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
}
}
}
}
Binary file added TwoCaptcha.Examples/resources/audio-en.mp3
Binary file not shown.
Binary file added TwoCaptcha.Examples/resources/audio-ru.mp3
Binary file not shown.
30 changes: 30 additions & 0 deletions TwoCaptcha.Tests/AmazonWafTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using NUnit.Framework;
using TwoCaptcha.Captcha;

namespace TwoCaptcha.Tests
{
[TestFixture]
public class AmazonWafTest : AbstractWrapperTestCase
{
[Test]
public async Task TestAllOptions()
{
AmazonWaf captcha = new AmazonWaf();
captcha.SetSiteKey("AQIDAHjcYu/GjX+QlghicBgQ/7bFaQZ+m5FKCMDnO+vTbNg96AF5H1K/siwSLK7RfstKtN5bAAAAfjB8BgkqhkiG9w0BBwagbzBtAgEAMGgGCSqGSIb3DQEHATAeBglg");
captcha.SetUrl("https://non-existent-example.execute-api.us-east-1.amazonaws.com");
captcha.SetContext("test_iv");
captcha.SetIV("test_context");

var parameters = new Dictionary<string, string>();
parameters["method"] = "amazon_waf";
parameters["sitekey"] = "AQIDAHjcYu/GjX+QlghicBgQ/7bFaQZ+m5FKCMDnO+vTbNg96AF5H1K/siwSLK7RfstKtN5bAAAAfjB8BgkqhkiG9w0BBwagbzBtAgEAMGgGCSqGSIb3DQEHATAeBglg";
parameters["pageurl"] = "https://non-existent-example.execute-api.us-east-1.amazonaws.com";
parameters["context"] = "test_iv";
parameters["iv"] = "test_context";

await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
}
}
}
36 changes: 36 additions & 0 deletions TwoCaptcha.Tests/AudioTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using NUnit.Framework;
using TwoCaptcha.Captcha;

namespace TwoCaptcha.Tests
{
[TestFixture]
public class AudioTest : AbstractWrapperTestCase
{

[Test]
public async Task TestAllParameters()
{
byte[] bytes = File.ReadAllBytes("../../../resources/audio-en.mp3");
string base64EncodedImage = Convert.ToBase64String(bytes);


AudioCaptcha captcha = new AudioCaptcha();
captcha.SetBase64(base64EncodedImage);
captcha.SetLang("en");


var parameters = new Dictionary<string, string>();
parameters["method"] = "audio";
parameters["lang"] = "en";
parameters["body"] = base64EncodedImage;


await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
}

}
}
28 changes: 28 additions & 0 deletions TwoCaptcha.Tests/GeeTestV4Test.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using NUnit.Framework;
using TwoCaptcha.Captcha;

namespace TwoCaptcha.Tests
{
[TestFixture]
public class GeeTestV4Test : AbstractWrapperTestCase
{
[Test]
public async Task TestAllOptions()
{
GeeTestV4 captcha = new GeeTestV4();
captcha.SetCaptchaId("72bf15796d0b69c43867452fea615052");
captcha.SetChallenge("12345678abc90123d45678ef90123a456b");
captcha.SetUrl("https://mysite.com/captcha.html");

var parameters = new Dictionary<string, string>();
parameters["method"] = "geetest_v4";
parameters["captcha_id"] = "72bf15796d0b69c43867452fea615052";
parameters["challenge"] = "12345678abc90123d45678ef90123a456b";
parameters["pageurl"] = "https://mysite.com/captcha.html";

await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
}
}
}
50 changes: 25 additions & 25 deletions TwoCaptcha.Tests/HCaptchaTest.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using NUnit.Framework;
using TwoCaptcha.Captcha;

namespace TwoCaptcha.Tests
{
[TestFixture]
public class HCaptchaTest : AbstractWrapperTestCase
{
[Test]
public async Task TestAllOptions()
{
HCaptcha captcha = new HCaptcha();
captcha.SetSiteKey("f1ab2cdefa3456789012345b6c78d90e");
captcha.SetUrl("https://www.site.com/page/");

var parameters = new Dictionary<string, string>();
parameters["method"] = "hcaptcha";
parameters["sitekey"] = "f1ab2cdefa3456789012345b6c78d90e";
parameters["pageurl"] = "https://www.site.com/page/";

await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
}
}
using System.Collections.Generic;
using System.Threading.Tasks;
using NUnit.Framework;
using TwoCaptcha.Captcha;
namespace TwoCaptcha.Tests
{
[TestFixture]
public class HCaptchaTest : AbstractWrapperTestCase
{
[Test]
public async Task TestAllOptions()
{
HCaptcha captcha = new HCaptcha();
captcha.SetSiteKey("f1ab2cdefa3456789012345b6c78d90e");
captcha.SetUrl("https://www.site.com/page/");
var parameters = new Dictionary<string, string>();
parameters["method"] = "hcaptcha";
parameters["sitekey"] = "f1ab2cdefa3456789012345b6c78d90e";
parameters["pageurl"] = "https://www.site.com/page/";
await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
}
}
}
28 changes: 28 additions & 0 deletions TwoCaptcha.Tests/LeminTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using NUnit.Framework;
using TwoCaptcha.Captcha;

namespace TwoCaptcha.Tests
{
[TestFixture]
public class LeminTest : AbstractWrapperTestCase
{
[Test]
public async Task TestAllOptions()
{
Lemin captcha = new Lemin();
captcha.SetCaptchaId("CROPPED_d3d4d56_73ca4008925b4f83a8bed59c2dd0df6d");
captcha.SetApiServer("api.leminnow.com");
captcha.SetUrl("http://sat2.aksigorta.com.tr");

var parameters = new Dictionary<string, string>();
parameters["method"] = "lemin";
parameters["captcha_id"] = "CROPPED_d3d4d56_73ca4008925b4f83a8bed59c2dd0df6d";
parameters["api_server"] = "api.leminnow.com";
parameters["pageurl"] = "http://sat2.aksigorta.com.tr";

await CheckIfCorrectParamsSendAndResultReturned(captcha, parameters);
}
}
}
Loading