Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
13180c5a
authored
2013-10-21 22:06:30 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix #249
1 parent
6ea8dd59
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
7 deletions
session/session.go
session/session.go
View file @
13180c5
...
...
@@ -217,24 +217,23 @@ func (manager *Manager) SessionRegenerateId(w http.ResponseWriter, r *http.Reque
//remote_addr cruunixnano randdata
func
(
manager
*
Manager
)
sessionId
(
r
*
http
.
Request
)
(
sid
string
)
{
b
:=
make
([]
byte
,
24
)
if
_
,
err
:=
io
.
ReadFull
(
rand
.
Reader
,
b
);
err
!=
nil
{
b
s
:=
make
([]
byte
,
24
)
if
_
,
err
:=
io
.
ReadFull
(
rand
.
Reader
,
b
s
);
err
!=
nil
{
return
""
}
bs
:=
base64
.
URLEncoding
.
EncodeToString
(
b
)
sig
:=
fmt
.
Sprintf
(
"%s%d%s"
,
r
.
RemoteAddr
,
time
.
Now
()
.
UnixNano
(),
bs
)
if
manager
.
hashfunc
==
"md5"
{
h
:=
md5
.
New
()
h
.
Write
([]
byte
(
bs
))
sid
=
fmt
.
Sprintf
(
"%s"
,
hex
.
EncodeToString
(
h
.
Sum
(
nil
)
))
h
.
Write
([]
byte
(
sig
))
sid
=
hex
.
EncodeToString
(
h
.
Sum
(
nil
))
}
else
if
manager
.
hashfunc
==
"sha1"
{
h
:=
hmac
.
New
(
sha1
.
New
,
[]
byte
(
manager
.
hashkey
))
fmt
.
Fprintf
(
h
,
"%s"
,
sig
)
sid
=
fmt
.
Sprintf
(
"%s"
,
hex
.
EncodeToString
(
h
.
Sum
(
nil
)
))
sid
=
hex
.
EncodeToString
(
h
.
Sum
(
nil
))
}
else
{
h
:=
hmac
.
New
(
sha1
.
New
,
[]
byte
(
manager
.
hashkey
))
fmt
.
Fprintf
(
h
,
"%s"
,
sig
)
sid
=
fmt
.
Sprintf
(
"%s"
,
hex
.
EncodeToString
(
h
.
Sum
(
nil
)
))
sid
=
hex
.
EncodeToString
(
h
.
Sum
(
nil
))
}
return
}
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment