@ -4,9 +4,8 @@
package pwn
package pwn
import (
import (
"math/rand "
"math/rand /v2 "
"net/http"
"net/http"
"os"
"strings"
"strings"
"testing"
"testing"
"time"
"time"
@ -18,11 +17,6 @@ var client = New(WithHTTP(&http.Client{
Timeout : time . Second * 2 ,
Timeout : time . Second * 2 ,
} ) )
} ) )
func TestMain ( m * testing . M ) {
rand . Seed ( time . Now ( ) . Unix ( ) )
os . Exit ( m . Run ( ) )
}
func TestPassword ( t * testing . T ) {
func TestPassword ( t * testing . T ) {
// Check input error
// Check input error
_ , err := client . CheckPassword ( "" , false )
_ , err := client . CheckPassword ( "" , false )
@ -81,24 +75,24 @@ func testPassword() string {
// Set special character
// Set special character
for i := 0 ; i < 5 ; i ++ {
for i := 0 ; i < 5 ; i ++ {
random := rand . Int n ( len ( specialCharSet ) )
random := rand . Int N ( len ( specialCharSet ) )
password . WriteString ( string ( specialCharSet [ random ] ) )
password . WriteString ( string ( specialCharSet [ random ] ) )
}
}
// Set numeric
// Set numeric
for i := 0 ; i < 5 ; i ++ {
for i := 0 ; i < 5 ; i ++ {
random := rand . Int n ( len ( numberSet ) )
random := rand . Int N ( len ( numberSet ) )
password . WriteString ( string ( numberSet [ random ] ) )
password . WriteString ( string ( numberSet [ random ] ) )
}
}
// Set uppercase
// Set uppercase
for i := 0 ; i < 5 ; i ++ {
for i := 0 ; i < 5 ; i ++ {
random := rand . Int n ( len ( upperCharSet ) )
random := rand . Int N ( len ( upperCharSet ) )
password . WriteString ( string ( upperCharSet [ random ] ) )
password . WriteString ( string ( upperCharSet [ random ] ) )
}
}
for i := 0 ; i < 5 ; i ++ {
for i := 0 ; i < 5 ; i ++ {
random := rand . Int n ( len ( allCharSet ) )
random := rand . Int N ( len ( allCharSet ) )
password . WriteString ( string ( allCharSet [ random ] ) )
password . WriteString ( string ( allCharSet [ random ] ) )
}
}
inRune := [ ] rune ( password . String ( ) )
inRune := [ ] rune ( password . String ( ) )