Skip to content
/ gcry Public

An exercise with some algorithms of encryption in Golang, like CBC, CFB, GCM, OFB, MD5, BLOWFIS etc.

Notifications You must be signed in to change notification settings

jeffotoni/gcry

Repository files navigation

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

- 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

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

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

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

package main

import (
	"fmt"
	gcry "github.com/jeffotoni/gcry"
)

func main() {

	fmt.Println(gcry.UidRand())
}

Using Sha1

package main

import (
	"fmt"
	gcry "github.com/jeffotoni/gcry"
)

func main() {

	password := "1234567890#$"

	hash := gcry.Sha1(password)

	fmt.Println(hash)
}

Using Blowfish

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

package main

import (
	"fmt"
	gcry "github.com/jeffotoni/gcry"
)

func main() {

	fmt.Println(gcry.BlowfishUid())
}

Using HashFile

package main

import (
	"fmt"
	gcry "github.com/jeffotoni/gcry"
)

func main() {

	hash, _ := gcry.HashFile("main-cbc.go")
	fmt.Println(hash)
}

Using Sha256

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.

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)
}

About

An exercise with some algorithms of encryption in Golang, like CBC, CFB, GCM, OFB, MD5, BLOWFIS etc.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages