go vet and lint
* Naming
* If this is not some OpenPGP standard I follow rule that `DES` should be
upper case as it is abreviation and `Triple` should be camel-case as it
is normal word hence `TripleDES`
* rename `errors2` -> `errorsPGP`
* long lines
* https://github.com/golang/go/wiki/CodeReviewComments#line-length
* I bit improved long lines based on my folding
* reuse type in definition if possible i.e. `a string, b string, c string` -> `a,b,c string`
* `if long_statetent(); err!=nil {` -> `long_statement;↵ if err!=nil {`
* spaces around operators (e.g. `a + b` -> `a+b`)
* removing empty lines on start and end of scope
* comments
* on all exported functions
* start with function name
* import:
* order in alphabet
* separate native, golang.org/x/ and our libs
This commit is contained in:
parent
e03fe86077
commit
78e3abb0d8
16 changed files with 302 additions and 164 deletions
|
|
@ -7,7 +7,8 @@ import (
|
|||
"golang.org/x/crypto/scrypt"
|
||||
)
|
||||
|
||||
// EncryptWithoutIntegrity encrypts data with AES-CTR. Note: this encryption mode is not secure when stored/sent on an untrusted medium.
|
||||
// EncryptWithoutIntegrity encrypts data with AES-CTR. Note: this encryption
|
||||
// mode is not secure when stored/sent on an untrusted medium.
|
||||
func EncryptWithoutIntegrity(key, input, iv []byte) (output []byte, err error) {
|
||||
var block cipher.Block
|
||||
if block, err = aes.NewCipher(key); err != nil {
|
||||
|
|
@ -25,7 +26,8 @@ func DecryptWithoutIntegrity(key, input, iv []byte) ([]byte, error) {
|
|||
return EncryptWithoutIntegrity(key, input, iv)
|
||||
}
|
||||
|
||||
// DeriveKey derives a key from a password using scrypt. N should be set to the highest power of 2 you can derive within 100 milliseconds.
|
||||
// DeriveKey derives a key from a password using scrypt. N should be set to the
|
||||
// highest power of 2 you can derive within 100 milliseconds.
|
||||
func DeriveKey(password string, salt []byte, N int) ([]byte, error) {
|
||||
return scrypt.Key([]byte(password), salt, N, 8, 1, 32)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue