SecureBase
ProjectsLibrariesQuick LinksFeedback
English
English
  • SecureBase
    • Demo Apps Screenshots
  • .NET
    • Installation
    • Usage
    • Version Notes
  • Delphi
    • Installation
    • Usage
    • Version Notes
  • Go
    • Installation
    • Usage
    • Version Notes
  • Java
    • Installation
    • Usage
    • Version Notes
  • Python
    • Installation
    • Usage
    • Version Notes
Powered by GitBook
On this page
  1. Java

Usage

PreviousInstallationNextVersion Notes

Last updated 6 months ago

CtrlK
//SecureBase.SBEncoding sbencoding = SecureBase.SBEncoding.UNICODE;
SecureBase.SBEncoding sbencoding = SecureBase.SBEncoding.UTF8;

SecureBase bs = new SecureBase(sbencoding);
bs.SetSecretKey(secretkey);

//Encoding
string encodeddata = bs.Encode(data);

//Decoding
string decodeddata = bs.Decode(data);
SecureBase sb = new SecureBase(SecureBase.SBEncoding.UTF8);
sb.SetSecretKey("xcompany-secret-key");

byte[] filedatabytes = Files.readAllBytes(Paths.get("data.txt"));
String filedata = new String(filedatabytes, StandardCharsets.UTF_8);

//Encoding
String encodeddata = sb.encode(filedata);
Files.write(Paths.get("encoded.txt"), encodeddata.getBytes(StandardCharsets.UTF_8));

//Decoding
String decodeddata = sb.decode(encodeddata);
Files.write(Paths.get("decoded.txt"), decodeddata.getBytes(StandardCharsets.UTF_8));

You can examine sample usage via the SecureBaseApp application on Github.