all repos — captcha @ e3eb22480f6e652f321e379501124c5c62318fc2

Go package captcha implements generation and verification of image and audio CAPTCHAs.

Add WriteAudio function.
Dmitry Chestnykh dmitry@codingrobots.com
Sat, 23 Apr 2011 18:44:02 +0200
commit

e3eb22480f6e652f321e379501124c5c62318fc2

parent

5357b20fc91de2905938534e511feb7a9d2887b9

1 files changed, 11 insertions(+), 0 deletions(-)

jump to
M captcha.gocaptcha.go

@@ -57,6 +57,17 @@ }

return NewImage(ns, width, height).PNGEncode(w) } +// WriteAudio writes WAV-encoded audio captcha with the given captcha id into +// the given io.Writer. +func WriteAudio(w io.Writer, id string) os.Error { + ns := globalStore.getNumbers(id) + if ns == nil { + return os.NewError("captcha id not found") + } + _, err := NewAudio(ns).WriteTo(w) + return err +} + // Verify returns true if the given numbers are the numbers that were used to // create the given captcha id. //