-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathccgen.go
50 lines (38 loc) · 885 Bytes
/
ccgen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package ccgen
import (
"fmt"
"math/rand"
"time"
)
//to ensure we don't create more than 500 cards
const MaxCount = 500
//generate credit card numbers
func GenerateCards(cardType string, count int) []Card {
// count, countError := strconv.Atoi(countString)
cardProperties, exists := Bin[cardType]
var errors Errors
if !exists {
errors = append(errors, Error{
Parameter: "type",
Issue: "invalid card type supplied",
})
}
if len(errors) > 0 {
fmt.Println(errors)
}
if count > MaxCount {
count = MaxCount
}
var cardList []Card
for i := 0; i < count; i++ {
rand.Seed(time.Now().UnixNano())
var card = Card{
Issuer: cardProperties.LongName,
Pan: GeneratePAN(cardProperties),
ExpiryDate: GenerateExpiryDate(),
CVV: GenerateCVV(cardProperties.CvvSize),
}
cardList = append(cardList, card)
}
return cardList
}