# Usage

{% tabs %}
{% tab title="Text" %}
```go
import (
	SecureBase "github.com/beytullahakyuz/securebase-go"
)

var encoding SecureBase.SBEncoding
//encoding = SecureBase.UNICODE
encoding = SecureBase.UTF8

sb := SecureBase.NewSecureBase(encoding)
sb.SetSecretKey(secretkey)

//Encoding
encoded, err := sb.Encode("data")
if err != nil {
	return err.Error()
}

//Decoding
decoded, err := sb.Decode(encoded)
if err != nil {
	return err.Error()
}
```
{% endtab %}

{% tab title="File" %}
```go
import (
	SecureBase "github.com/beytullahakyuz/securebase-go"
)

var encoding SecureBase.SBEncoding
//encoding = SecureBase.UNICODE
encoding = SecureBase.UTF8

sb := SecureBase.NewSecureBase(encoding)
sb.SetSecretKey(secretkey)

//Encoding
encoded, err := sb.Encode("data")
if err != nil {
	return err.Error()
}

//Decoding
decoded, err := sb.Decode(encoded)
if err != nil {
secbase := SecureBase.NewSecureBase(SecureBase.UTF8)
secbase.SetSecretKey("SET-SECRET-KEY")

filebytes, err := os.ReadFile("data.txt")
if err != nil {
	fmt.Println("File read error!")
}

filedata := string(filebytes)
encodeddata, _ := secbase.Encode(filedata)
os.WriteFile("encoded.txt", []byte(encodeddata), os.FileMode(os.O_CREATE))

decodeddata, _ := secbase.Decode(encodeddata)
os.WriteFile("decoded.txt", []byte(decodeddata), os.FileMode(os.O_CREATE))
```
{% endtab %}
{% endtabs %}

{% hint style="info" %}
You can examine sample usage via the [SecureBaseApp](https://github.com/beytullahakyuz/securebase-go/releases/tag/SecureBaseApp) application on Github.
{% endhint %}

***
