C# Class VisualCaptcha.Captcha

ファイルを表示 Open project: lukeautry/visualCaptcha-aspnet Class Usage Examples

Public Properties

Property Type Description
PossibleImageOptions string>.ImmutableDictionary
ValidAudioOption string>.KeyValuePair
ValidImageOption string>.KeyValuePair

Public Methods

Method Description
Captcha ( int numberOfImageOptions ) : System

Instantiate a Captcha session with an assortment of possible image selections and an audio option for accessibility

GetAudio ( string type ) : byte[]

Get file content for audio Captcha option

GetFrontEndData ( ) : FrontEndData

Retrieve object containing information needed by client-side library

GetImage ( int index, bool isRetina ) : byte[]

Get file content for image Captcha option

ValidateAnswer ( string answerValue ) : bool

Answer value is valid for either image or audio option

Private Methods

Method Description
GetRandomImageOptions ( int numberOfOptions ) : string>.ImmutableDictionary
GetRandomOption ( string>.ICollection options ) : string>.KeyValuePair
IsValidAudio ( string value ) : bool
IsValidImage ( string hashedPath ) : bool
ReadResource ( string optionPath ) : byte[]

Method Details

Captcha() public method

Instantiate a Captcha session with an assortment of possible image selections and an audio option for accessibility
public Captcha ( int numberOfImageOptions ) : System
numberOfImageOptions int
return System

GetAudio() public method

Get file content for audio Captcha option
public GetAudio ( string type ) : byte[]
type string Either mp3 or ogg
return byte[]

GetFrontEndData() public method

Retrieve object containing information needed by client-side library
public GetFrontEndData ( ) : FrontEndData
return FrontEndData

GetImage() public method

Get file content for image Captcha option
public GetImage ( int index, bool isRetina ) : byte[]
index int Image index
isRetina bool Uses Retina display
return byte[]

ValidateAnswer() public method

Answer value is valid for either image or audio option
public ValidateAnswer ( string answerValue ) : bool
answerValue string This could be the hashed value of the image path or the answer to an audio question
return bool

Property Details

PossibleImageOptions public_oe property

Dictionary of possible images to be displayed client-side Key: The image name (e.g. "Cloud") Value: The hashed value of the image path (e.g. "Cloud.png" --> "198723lkdjlfiwoekjdlsd")
public ImmutableDictionary PossibleImageOptions
return string>.ImmutableDictionary

ValidAudioOption public_oe property

The correct question/answer pair for audio accessibility option
public KeyValuePair ValidAudioOption
return string>.KeyValuePair

ValidImageOption public_oe property

The correct selection out of the options contained in PossibleImageOptions
public KeyValuePair ValidImageOption
return string>.KeyValuePair