Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jeffotoni/gcry
An exercise with some algorithms of encryption in Golang, like CBC, CFB, GCM, OFB, MD5, BLOWFIS etc.
https://github.com/jeffotoni/gcry
blowfish-algorithm criptografia criptography crypto-cbc crypto-coin cryptography go golang
Last synced: 19 days ago
JSON representation
An exercise with some algorithms of encryption in Golang, like CBC, CFB, GCM, OFB, MD5, BLOWFIS etc.
- Host: GitHub
- URL: https://github.com/jeffotoni/gcry
- Owner: jeffotoni
- Created: 2017-09-30T17:19:16.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-20T02:13:39.000Z (over 6 years ago)
- Last Synced: 2024-06-20T07:39:06.414Z (5 months ago)
- Topics: blowfish-algorithm, criptografia, criptography, crypto-cbc, crypto-coin, cryptography, go, golang
- Language: Go
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gcry
Lib that abstracts the encryption algorithms used by golang.
The goal is to further facilitate the native ualization of existing libs in Go.
We use numbers like CBC, CFB, GCM, OFB, MD5, BLOWFISH etc.
## Structure of the program
```go
- gcry
- example
- main-blofish-uid-rand.go
- main-blofish.go
- main-cbc.go
- main-cfb.go
- main-gcm.go
- main-hash-file.go
- main-sh1.go
- main-uid-rand.go- api-blofish-uid-rand.go
- api-blofish.go
- api-cbc.go
- api-cfb.go
- api-gcm.go
- api-hash-file.go
- api-sh1.go
- api-uid-rand.go```
# Using EncryptGCM
```go
package main
import (
"fmt"
gcry "github.com/jeffotoni/gcry"
)fsunc main() {
textCry := gcry.EncryptGCM("Let's encrypt our text here.")
fmt.Println(textCry)textDescry := gcry.DecryptGCM(textCry)
fmt.Println(textDescry)
}```
# Using EncryptCFB
```go
package main
import (
"fmt"
gcry "github.com/jeffotoni/gcry"
)//
//
//
func main() {cipherText := gcry.EncryptCFB("new functional ex: of crifra CFB ")
fmt.Println(cipherText)
textplan := gcry.DecryptCFB(cipherText)
fmt.Println(textplan)
}```
# Using EncryptCBC
```go
package main
import (
"fmt"
gcry "github.com/jeffotoni/gcry"
)//
//
//
func main() {// multiple 16 len text
cipherText := gcry.EncryptCBC("new functional ex: of crifra CBC")fmt.Println(cipherText)
textplan := gcry.DecryptCBC(cipherText)
fmt.Println(textplan)
}```
# Using Uid Rand
```go
package main
import (
"fmt"
gcry "github.com/jeffotoni/gcry"
)func main() {
fmt.Println(gcry.UidRand())
}```
# Using Sha1
```go
package main
import (
"fmt"
gcry "github.com/jeffotoni/gcry"
)func main() {
password := "1234567890#$"
hash := gcry.Sha1(password)
fmt.Println(hash)
}```
# Using Blowfish
```go
package main
import (
"fmt"
gcry "github.com/jeffotoni/gcry"
)func main() {
password := "1234567890#$"
hashBlo := gcry.Blowfish(password)
if gcry.CheckBlowfish(password, hashBlo) {
fmt.Println("ok, password correct!")
} else {
fmt.Println("ok, password incorrect!")
}}
```
# Using Blowfish Uid
```go
package main
import (
"fmt"
gcry "github.com/jeffotoni/gcry"
)func main() {
fmt.Println(gcry.BlowfishUid())
}```
# Using HashFile
```go
package main
import (
"fmt"
gcry "github.com/jeffotoni/gcry"
)func main() {
hash, _ := gcry.HashFile("main-cbc.go")
fmt.Println(hash)
}```
# Using Sha256
```go
package main
import (
"fmt"
gcry "github.com/jeffotoni/gcry"
)func main() {
password := "1234567890#$"
hash := gcry.Sha256(password)
}```
# Using OFB File
It is possible to encrypt files, ie your content will be encrypted and generated a new file.
```go
package main
import (
"fmt"
gcry "github.com/jeffotoni/gcry"
)func main() {
fileCry := gcry.EncryptOFBFile("main-cbc.go")fmt.Println(fileCry)
fileDecry := gcry.DecryptOFBFile(fileCry)
fmt.Println(fileDecry)
}```