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
coreospackage
Commits
038f6034
Commit
038f6034
authored
7 years ago
by
Sandeep S. Shewalkar
Browse files
Options
Downloads
Patches
Plain Diff
Security helper and compression helper added
parent
221f5df7
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
compressionHelper.go
+16
-0
compressionHelper.go
glide.yaml
+2
-9
glide.yaml
securityHelper.go
+71
-0
securityHelper.go
with
89 additions
and
9 deletions
compressionHelper.go
0 → 100644
+
16
−
0
View file @
038f6034
package
coreos
import
"github.com/DataDog/zstd"
//Compress Compress
func
Compress
(
inputData
[]
byte
)
([]
byte
,
error
)
{
compressedData
,
err
:=
zstd
.
Compress
(
nil
,
inputData
)
return
compressedData
,
err
}
// Decompress Decompress
func
Decompress
(
compressedData
[]
byte
)
([]
byte
,
error
)
{
decompressedData
,
err
:=
zstd
.
Decompress
(
nil
,
compressedData
)
return
decompressedData
,
err
}
This diff is collapsed.
Click to expand it.
glide.yaml
+
2
−
9
View file @
038f6034
package
:
.
package
:
.
import
:
import
:
-
package
:
github.com/DataDog/zstd
-
package
:
github.com/OneOfOne/xxhash
-
package
:
github.com/allegro/bigcache
-
package
:
github.com/allegro/bigcache
-
package
:
github.com/dgrijalva/jwt-go
-
package
:
github.com/dgrijalva/jwt-go
version
:
v3.0.0
-
package
:
github.com/garyburd/redigo
-
package
:
github.com/garyburd/redigo
version
:
v1.1.0
subpackages
:
subpackages
:
-
redis
-
redis
-
package
:
github.com/go-playground/locales
-
package
:
github.com/go-playground/locales
version
:
v0.11.1
subpackages
:
subpackages
:
-
en
-
en
-
package
:
github.com/go-playground/universal-translator
-
package
:
github.com/go-playground/universal-translator
version
:
v0.16.0
-
package
:
github.com/gocraft/dbr
-
package
:
github.com/gocraft/dbr
version
:
v2.1
-
package
:
github.com/labstack/echo
-
package
:
github.com/labstack/echo
version
:
v3.2.1
subpackages
:
subpackages
:
-
middleware
-
middleware
-
package
:
github.com/sirupsen/logrus
-
package
:
github.com/sirupsen/logrus
version
:
v1.0.1
-
package
:
gopkg.in/go-playground/validator.v9
-
package
:
gopkg.in/go-playground/validator.v9
version
:
v9.4.0
subpackages
:
subpackages
:
-
translations/en
-
translations/en
-
package
:
gopkg.in/mgo.v2
-
package
:
gopkg.in/mgo.v2
...
@@ -30,6 +24,5 @@ import:
...
@@ -30,6 +24,5 @@ import:
-
bson
-
bson
testImport
:
testImport
:
-
package
:
github.com/stretchr/testify
-
package
:
github.com/stretchr/testify
version
:
v1.1.4
subpackages
:
subpackages
:
-
assert
-
assert
This diff is collapsed.
Click to expand it.
securityHelper.go
0 → 100644
+
71
−
0
View file @
038f6034
package
coreos
import
(
"bytes"
"crypto/aes"
"crypto/cipher"
"encoding/base64"
"github.com/OneOfOne/xxhash"
)
const
(
IV
=
"AAAAAAAAAAAAAAAA"
)
//AESEncrypt Encrypts given text
func
AESEncrypt
(
plainText
,
key
[]
byte
)
[]
byte
{
block
,
err
:=
aes
.
NewCipher
(
key
)
if
err
!=
nil
{
panic
(
err
)
}
padding
:=
block
.
BlockSize
()
-
len
(
plainText
)
%
block
.
BlockSize
()
padtext
:=
bytes
.
Repeat
([]
byte
{
byte
(
padding
)},
padding
)
plainText
=
append
(
plainText
,
padtext
...
)
cipherText
:=
make
([]
byte
,
len
(
plainText
))
cbc
:=
cipher
.
NewCBCEncrypter
(
block
,
[]
byte
(
IV
))
cbc
.
CryptBlocks
(
cipherText
,
plainText
)
encodedData
:=
make
([]
byte
,
base64
.
StdEncoding
.
EncodedLen
(
len
(
plainText
)))
base64
.
StdEncoding
.
Encode
(
encodedData
,
cipherText
)
return
encodedData
}
//AESDecrypt Decrypts given cipher text
func
AESDecrypt
(
encodedData
,
key
[]
byte
)
[]
byte
{
decodedData
:=
make
([]
byte
,
base64
.
StdEncoding
.
DecodedLen
(
len
(
encodedData
)))
n
,
err
:=
base64
.
StdEncoding
.
Decode
(
decodedData
,
encodedData
)
if
err
!=
nil
{
panic
(
err
)
}
cipherText
:=
decodedData
[
:
n
]
block
,
err
:=
aes
.
NewCipher
(
key
)
if
err
!=
nil
{
panic
(
err
)
}
cbc
:=
cipher
.
NewCBCDecrypter
(
block
,
[]
byte
(
IV
))
cbc
.
CryptBlocks
(
cipherText
,
cipherText
)
length
:=
len
(
cipherText
)
unpadding
:=
int
(
cipherText
[
length
-
1
])
return
cipherText
[
:
(
length
-
unpadding
)]
}
//GetHashChecksum Get Hash Check sum
func
GetHashChecksum
(
byteArray
[]
byte
)
uint64
{
h
:=
xxhash
.
New64
()
h
.
Write
(
byteArray
)
return
h
.
Sum64
()
}
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