aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/crypto.go
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2015-03-25 22:58:52 +0800
committerzelig <viktor.tron@gmail.com>2015-03-27 03:00:18 +0800
commit4ec38e39320ee9abccd96da765a9c65fccd04151 (patch)
tree3f57aebae8bd42f766b80a3db5e3b22328e9a181 /crypto/crypto.go
parent23e41a57ad7e7cb4bc5a1cbad28bbf8d65907fdd (diff)
downloadgo-tangerine-4ec38e39320ee9abccd96da765a9c65fccd04151.tar
go-tangerine-4ec38e39320ee9abccd96da765a9c65fccd04151.tar.gz
go-tangerine-4ec38e39320ee9abccd96da765a9c65fccd04151.tar.bz2
go-tangerine-4ec38e39320ee9abccd96da765a9c65fccd04151.tar.lz
go-tangerine-4ec38e39320ee9abccd96da765a9c65fccd04151.tar.xz
go-tangerine-4ec38e39320ee9abccd96da765a9c65fccd04151.tar.zst
go-tangerine-4ec38e39320ee9abccd96da765a9c65fccd04151.zip
common: remove WriteFile and ReadAllFile (use ioutil instead)
Diffstat (limited to 'crypto/crypto.go')
-rw-r--r--crypto/crypto.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/crypto/crypto.go b/crypto/crypto.go
index 2d26dd25e..442942c6c 100644
--- a/crypto/crypto.go
+++ b/crypto/crypto.go
@@ -9,6 +9,7 @@ import (
"crypto/sha256"
"fmt"
"io"
+ "io/ioutil"
"os"
"encoding/hex"
@@ -139,9 +140,10 @@ func LoadECDSA(file string) (*ecdsa.PrivateKey, error) {
return ToECDSA(buf), nil
}
-// SaveECDSA saves a secp256k1 private key from the given file.
+// SaveECDSA saves a secp256k1 private key to the given file with restrictive
+// permissions
func SaveECDSA(file string, key *ecdsa.PrivateKey) error {
- return common.WriteFile(file, FromECDSA(key))
+ return ioutil.WriteFile(file, FromECDSA(key), 0600)
}
func GenerateKey() (*ecdsa.PrivateKey, error) {