Last active
December 29, 2015 07:09
-
-
Save naimakin/7634100 to your computer and use it in GitHub Desktop.
programlama dilleri ödevi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "math/rand" | |
| "github.com/ActiveState/golor" | |
| "time" | |
| "bytes" | |
| "strconv" | |
| ) | |
| type PasswordCard struct { | |
| colors []int | |
| } | |
| func main() { | |
| header:=" ■□▲△○●★☂☀☁☹☺♠♣♥♦♫€¥£$!?¡¿⊙◐◩ � " | |
| fmt.Println(header) | |
| for i:=0 ; i<9 ; i++ { | |
| for k:=0 ; k<1 ; k++ { | |
| t := strconv.Itoa(i) | |
| fmt.Println(t+" "+randomString(10)) | |
| } | |
| } | |
| } | |
| /*randimum değerleri atama*/ | |
| func randomString (l int) string { | |
| p.colors() | |
| var result bytes.Buffer | |
| var temp string | |
| for i:=0 ; i<l ; { | |
| if string(randInt(48,122))!=temp { | |
| temp=string(randInt(65,90))+string(randInt(48,57))+string(randInt(97,122)) | |
| result.WriteString(golor.Colorize(temp, -1, p.colors[i])) | |
| i++ | |
| } | |
| } | |
| return result.String() | |
| } | |
| func randInt(min int , max int) int { | |
| rand.Seed(time.Now().UTC().UnixNano()) | |
| return min + rand.Intn(max-min) | |
| } | |
| func (p PasswordCard) colors() { | |
| p.colors = []int{golor.CYAN, golor.RED, golor.YELLOW, golor.BLUE, | |
| golor.MAGENTA, golor.GREEN, golor.GRAY,golor.WHITE} | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment