Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
MKCLOS
Core Development Platform
corepkgv2
Commits
989bfcf4
Commit
989bfcf4
authored
6 years ago
by
Mayuri Shinde
Browse files
Options
Downloads
Patches
Plain Diff
Constants added in constantmdl
parent
e4c003a8
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!23
Devbranch to Master
,
!18
Securitymdl :SecurityKeyCreator and PasswordSalt
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
constantmdl/constantmdl.go
+15
-0
constantmdl/constantmdl.go
securitymdl/securitymdl.go
+3
-17
securitymdl/securitymdl.go
with
18 additions
and
17 deletions
constantmdl/constantmdl.go
+
15
−
0
View file @
989bfcf4
...
...
@@ -30,3 +30,18 @@ const IDLECONNTIMEOUT = time.Second * 90
// TASKCOUNT is used as default task count in filepipe
const
TASKCOUNT
=
5
// constants used for CreateSecurityKey function in securitymdl
const
(
MAX_RANDOM_STRING_LENGTH
=
256
RANDOM_STRING_LENGTH
=
16
NUMBERS_PERCENT
=
10
SMALL_CHARS_PERCENT
=
40
CAP_CHARS_PERCENT
=
40
SPECIAL_CHARS_PERCENT
=
10
CharSet
=
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&'()*+,-./:;<=>?@[]^_`{|}~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&'()*+,-./:;<=>?@[]^_`{|}~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&'()*@"
NUMBERS_SET
=
"0123456789"
SMALL_CHARS_SET
=
"abcdefghijklmnopqrstuvwxyz"
CAP_CHARS_SET
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
SPECIAL_CHARS_SET
=
"!#$%&'()*+,-./:;<=>?@[]^_`{|}~"
)
This diff is collapsed.
Click to expand it.
securitymdl/securitymdl.go
+
3
−
17
View file @
989bfcf4
...
...
@@ -8,6 +8,7 @@ import (
"math/rand"
"time"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/constantmdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/errormdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/loggermdl"
"golang.org/x/crypto/bcrypt"
...
...
@@ -169,28 +170,13 @@ func AESDecrypt(encodedData, key []byte) ([]byte, error) {
// return byteArray, nil
// }
// First
const
(
MAX_RANDOM_STRING_LENGTH
=
256
RANDOM_STRING_LENGTH
=
16
NUMBERS_PERCENT
=
10
SMALL_CHARS_PERCENT
=
40
CAP_CHARS_PERCENT
=
40
SPECIAL_CHARS_PERCENT
=
10
charSet
=
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&'()*+,-./:;<=>?@[]^_`{|}~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&'()*+,-./:;<=>?@[]^_`{|}~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&'()*@"
numebersSet
=
"0123456789"
smallCharSet
=
"abcdefghijklmnopqrstuvwxyz"
capCharSet
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
specialCharSet
=
"!#$%&'()*+,-./:;<=>?@[]^_`{|}~"
)
// CreateSecurityKey generates random string of given length
func
CreateSecurityKey
(
keyLength
int
)
(
string
,
error
)
{
if
keyLength
<=
MAX_RANDOM_STRING_LENGTH
{
if
keyLength
<=
constantmdl
.
MAX_RANDOM_STRING_LENGTH
{
seededRand
:=
rand
.
New
(
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
b
:=
make
([]
byte
,
keyLength
)
for
i
:=
range
b
{
b
[
i
]
=
charSet
[
seededRand
.
Intn
(
keyLength
)]
b
[
i
]
=
c
onstantmdl
.
C
harSet
[
seededRand
.
Intn
(
keyLength
)]
}
return
string
(
b
),
nil
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets