fileencryption

package module
v0.0.0-...-18fc48f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2018 License: MIT Imports: 7 Imported by: 0

README

Go-File-Encryption

Build Status license

Introduction

  • A file encryption/decryption library that uses the same algorithm as OpenSSL's with IV and salt
  • You can set key and IV manually instead of creating them from password and salt.

!!!Caution!!!

  • OpenSSL's key creation algorithm with password and salt is NOT secure.
  • You should set key and IV manually or use some alternative algorithms.

Examples

  • Read cbc_test.go

License

  • Under the MIT License
  • Copyright (c) 2017 Tsuzu

Documentation

Overview

Copyright (c) 2017 Tsuzu

This software is released under the MIT License. https://opensource.org/licenses/MIT

This software is released under the MIT License. https://opensource.org/licenses/MIT

Index

Constants

View Source
const BlockSize = 128 / 8
View Source
const BufReadLength = BlockSize * 2048
View Source
const SaltSize = BlockSize / 2

Variables

View Source
var ErrIllegalLengthOfkey = errors.New("Illegal length of key")
View Source
var ErrIllegalPadding = errors.New("Illegal Padding")
View Source
var ErrIllegalPrefixOfEncrypted = errors.New("Illegal Prefix of Encrypted")
View Source
var ErrInsufficientData = errors.New("Insufficient Data")
View Source
var SaltPrefix = []byte("Salted__")

Functions

func CreateKeyIVForAES128

func CreateKeyIVForAES128(password string, salt []byte) ([]byte, []byte)

[DEPRECETED] This is the same as OpenSSL's, but it is insecure.

func CreateKeyIVForAES256

func CreateKeyIVForAES256(password string, salt []byte) ([]byte, []byte)

[DEPRECETED] This is the same as OpenSSL's, but it is insecure.

func CreateSalt

func CreateSalt() ([]byte, error)

func PBKDF1

func PBKDF1(password, salt []byte) ([]byte, []byte)

func ReadByteChannelForFixedSize

func ReadByteChannelForFixedSize(ch chan byte, length int) []byte

func SendByteArrayToChannel

func SendByteArrayToChannel(b []byte, ch chan byte)

Types

type CBCDecryptionStream

type CBCDecryptionStream struct {
	Password string
	Key      []byte
	IV       []byte
	Salt     []byte
	EOFFlag  bool
	// contains filtered or unexported fields
}

func NewCBCDecryptionStream

func NewCBCDecryptionStream(keyLen int, password string, reader io.Reader) (*CBCDecryptionStream, error)

keyLen only supports 128 or 256

func (*CBCDecryptionStream) Read

func (stream *CBCDecryptionStream) Read(b []byte) (retLength int, retError error)

type CBCEncryptionStream

type CBCEncryptionStream struct {
	Password string
	Key      []byte
	IV       []byte
	Salt     []byte
	EOFFlag  bool
	// contains filtered or unexported fields
}

func NewCBCEncryptionStream

func NewCBCEncryptionStream(keyLen int, password string, reader io.Reader) (*CBCEncryptionStream, error)

keyLen only supports 128 or 256

func (*CBCEncryptionStream) Read

func (stream *CBCEncryptionStream) Read(b []byte) (retLength int, retError error)

type CrytionStream

type CrytionStream interface {
	io.Reader
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL