Giter VIP home page Giter VIP logo

godot_xor_encryption's Introduction

Godot XOR encryption / decryption

Two simple functions to encrypt / decrypt a string in Godot Engine.

Usage:

  var enc = xor_encrypt("Hello World!", "secretpassword");
  var result = xor_decrypt(enc, "secretpassword");

godot_xor_encryption's People

Contributors

toxiccrack avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

godot_xor_encryption's Issues

Method in GDNative for performance

I've done a similar method in GDNative (c++) to keep a higher performance. Free to use.

To call it in Godot, simply do:
var str = XOREncrypt.new()
str.value = "myString"

It will have xor encryption in memory. If you do print(str.value), it prints the original string. I've also added a validator, so that if someone tries to hack it, it will crash the game.

const int XOREncrypt::_validator_offset = Math::rand();
const int XOREncrypt::_key = Math::rand();
  
  void XOREncrypt::_bind_methods()
  {
    ClassDB::bind_method(D_METHOD("get"), &XOREncrypt::get);
    ClassDB::bind_method(D_METHOD("set"), &XOREncrypt::set);
    ADD_PROPERTY(PropertyInfo(Variant::INT, "value"), "set", "get");
  }
  
  void XOREncrypt::set(String const& value)
  {
    _validator = _validator_offset - value.hash();
    int size = value.size();
    if (size > 0)
    {
      _value.resize(size);
      for (int i = 0; i < size; ++i)
      {
        _value[i] = value[i] ^ _key;
      }
    }
  }
  
  String XOREncrypt::get() const
  {
    String value;
    int size = _value.size();
    if (size > 0)
    {
      value.resize(size);
      for (int i = 0; i < size; ++i)
      {
        value[i] = _value[i] ^ _key;
      }
    }
    
    if (_validator != _validator_offset - value.hash())
    {
      ERR_PRINTS("String not declared");
      CRASH_NOW();
    }
    return value;
  }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.