You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
667 B
28 lines
667 B
2 months ago
|
package msg
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"math/rand"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
type SmsOperation interface {
|
||
|
SendVerificationCode(phoneNumber string) (string, error)
|
||
|
CheckVerificationCode(phoneNumber, verificationCode string) error
|
||
|
CheckVerificationCodeNew(phoneNumber string) (string, error)
|
||
|
}
|
||
|
|
||
|
func NewSms() SmsOperation {
|
||
|
return getALiYunEntity()
|
||
|
}
|
||
|
|
||
|
// Create 6-bit random numbers
|
||
|
func CreateRandCode() string {
|
||
|
return fmt.Sprintf("%06v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(1000000))
|
||
|
}
|
||
|
|
||
|
// Create a 14 bit random number as the sender
|
||
|
func CreateRandCodeTest() string {
|
||
|
return fmt.Sprintf("%014v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(1000000))
|
||
|
}
|