Skip to content

Instantly share code, notes, and snippets.

@nilsding
Created July 3, 2014 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nilsding/558e7c65e75f2c3f93e7 to your computer and use it in GitHub Desktop.
Save nilsding/558e7c65e75f2c3f93e7 to your computer and use it in GitHub Desktop.
checks if a Twoffein3 API key is valid
using System;
using System.Text.RegularExpressions;
namespace Twoffein
{
class Helpers
{
public static bool checkApiKey (string apiKey)
{
Regex r = new Regex (@"^[A-GI-MP-RT-VX-Z]{3}\d{2}[A-GI-MP-RT-VX-Z]{7}\d{2}[A-GI-MP-RT-VX-Z]{2}$");
return r.IsMatch(apiKey);
}
}
}
var checkApiKey = function(apiKey) {
return /^[A-GI-MP-RT-VX-Z]{3}\d{2}[A-GI-MP-RT-VX-Z]{7}\d{2}[A-GI-MP-RT-VX-Z]{2}$/.test(apiKey);
};
#!/usr/bin/env ruby
##
# Returns true if `api_key` is a valid Twoffein3 API key
def check_api_key(api_key)
!/^[A-GI-MP-RT-VX-Z]{3}\d{2}[A-GI-MP-RT-VX-Z]{7}\d{2}[A-GI-MP-RT-VX-Z]{2}$/.match(api_key).nil?
end
puts check_api_key ARGV[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment