func AESEncrypt(plaintext []byte, password string) []byte {
	passwordHash := hashPassword(password)

	block, err := aes.NewCipher(passwordHash)
	if err != nil {
		panic(err)
	}

	aesgcm, err := cipher.NewGCM(block)
	if err != nil {
		panic(err)
	}

	nonce := make([]byte, aesgcm.NonceSize())
	if _, err = io.ReadFull(rand.Reader, nonce); err != nil {
		panic(err)
	}

	ciphertext := aesgcm.Seal(nil, nonce, plaintext, nil)
	log.Printf("ciphertext: %x\n", ciphertext)
	log.Printf("nonce: %x\n", nonce)
	ciphertext = append(ciphertext, nonce...) // suffix with nonce
	log.Printf("ciphertext: %x\n", ciphertext[:len(ciphertext)-len(nonce)])
	log.Printf("nonce: %x\n", ciphertext[len(ciphertext)-len(nonce):])

	ciphertext = append([]byte("AESENCRYPT"), ciphertext...) // prefix with magic id

	log.Printf("data out: %x\n", ciphertext)

	log.Println("Wallet encrypted")
	return ciphertext
}
// AESEncrypt when given some plaintext and a password,
// returns the AES ciphertext concatted with the nonce
AESEncrypt when given some plaintext and a password,
returns the AES ciphertext concatted with the nonce
// AESEncrypt when given some plaintext and a password // returns the AES ciphertext concatted with the nonce
func AESEncrypt(plaintext []byte, password string) []byte {
	passwordHash := hashPassword(password)
	block, err := aes.NewCipher(passwordHash)
	if err != nil {
		panic(err)
	}
	aesgcm, err := cipher.NewGCM(block)
	if err != nil {
		panic(err)
	}
	nonce := make([]byte, aesgcm.NonceSize())
	if _, err = io.ReadFull(rand.Reader, nonce); err != nil {
		panic(err)
	}
	ciphertext := aesgcm.Seal(nil, nonce, plaintext, nil)
	log.Printf("ciphertext: %x\n", ciphertext)
	log.Printf("nonce: %x\n", nonce)
	ciphertext = append(ciphertext, nonce...) 
	log.Printf("ciphertext: %x\n", ciphertext[:len(ciphertext)-len(nonce)])
	log.Printf("nonce: %x\n", ciphertext[len(ciphertext)-len(nonce):])
	ciphertext = append([]byte("AESENCRYPT"), ciphertext...) 
	log.Printf("data out: %x\n", ciphertext)
	log.Println("Wallet encrypted")
	return ciphertext
}
func AESEncrypt ( plaintext [ ] byte , password string ) [ ] byte { passwordHash := hashPassword ( password ) block , err := aes . NewCipher ( passwordHash ) if err != nil { panic ( err ) } aesgcm , err := cipher . NewGCM ( block ) if err != nil { panic ( err ) } nonce := make ( [ ] byte , aesgcm . NonceSize ( ) ) if _ , err = io . ReadFull ( rand . Reader , nonce ) ; err != nil { panic ( err ) } ciphertext := aesgcm . Seal ( nil , nonce , plaintext , nil ) log . Printf ( " \n " , ciphertext ) log . Printf ( " \n " , nonce ) ciphertext = append ( ciphertext , nonce ... ) log . Printf ( " \n " , ciphertext [ : len ( ciphertext ) - len ( nonce ) ] ) log . Printf ( " \n " , ciphertext [ len ( ciphertext ) - len ( nonce ) : ] ) ciphertext = append ( [ ] byte ( " " ) , ciphertext ... ) log . Printf ( " \n " , ciphertext ) log . Println ( " " ) return ciphertext }
AESEncrypt when given some plaintext and a password,
returns the AES ciphertext concatted with the nonce
AESEncrypt when given some plaintext and a password returns the AES ciphertext concatted with the nonce
// suffix with nonce // prefix with magic id