(pass string, saltSecret string, salt string, interation int64)
| 65 | } |
| 66 | |
| 67 | func hash(pass string, saltSecret string, salt string, interation int64) (string, error) { |
| 68 | var passSalt = saltSecret + pass + salt + saltSecret + pass + salt + pass + pass + salt |
| 69 | var i int |
| 70 | |
| 71 | hashPass := saltLocalSecret |
| 72 | hashStart := sha512.New() |
| 73 | hashCenter := sha256.New() |
| 74 | hashOutput := sha256.New224() |
| 75 | |
| 76 | i = 0 |
| 77 | for i <= stretchingPassword { |
| 78 | i = i + 1 |
| 79 | hashStart.Write([]byte(passSalt + hashPass)) |
| 80 | hashPass = hex.EncodeToString(hashStart.Sum(nil)) |
| 81 | } |
| 82 | |
| 83 | i = 0 |
| 84 | for int64(i) <= interation { |
| 85 | i = i + 1 |
| 86 | hashPass = hashPass + hashPass |
| 87 | } |
| 88 | |
| 89 | i = 0 |
| 90 | for i <= stretchingPassword { |
| 91 | i = i + 1 |
| 92 | hashCenter.Write([]byte(hashPass + saltSecret)) |
| 93 | hashPass = hex.EncodeToString(hashCenter.Sum(nil)) |
| 94 | } |
| 95 | hashOutput.Write([]byte(hashPass + saltLocalSecret)) |
| 96 | hashPass = hex.EncodeToString(hashOutput.Sum(nil)) |
| 97 | |
| 98 | return hashPass, nil |
| 99 | } |
| 100 | |
| 101 | func trimSaltHash(hash string) map[string]string { |
| 102 | str := strings.Split(hash, delimiter) |
no outgoing calls
no test coverage detected